系统组合框控件
更多...
#include <SysComboBox.h>
|
| SysComboBox () |
|
| SysComboBox (HWND hParent, RECT rct, std::wstring strText=L"") |
|
| SysComboBox (HWND hParent, int x, int y, int w, int h, std::wstring strText=L"") |
|
void | PreSetStyle (PreStyle pre_style) |
| 在创建控件前预设样式 更多...
|
|
LRESULT | UpdateMessage (UINT msg, WPARAM wParam, LPARAM lParam, bool &bRet) override |
| 更新消息,此函数无需用户调用 更多...
|
|
void | RegisterSelMessage (void(*pFunc)(int sel, std::wstring wstrSelText)) |
| 注册选择消息 更多...
|
|
void | RegisterEditMessage (void(*pFunc)(std::wstring wstrText)) |
| 注册编辑消息 更多...
|
|
int | GetSel () const |
| 获取选中的索引 更多...
|
|
void | SetSel (int sel) |
| 设置选中的索引 更多...
|
|
bool | SelectString (std::wstring wstrText) |
| 选择具有指定文本的一项 更多...
|
|
void | AddString (std::wstring wstrText) |
| 增加项 更多...
|
|
void | InsertString (int index, std::wstring wstrText) |
| 插入项 更多...
|
|
void | DeleteString (int index) |
| 删除项 更多...
|
|
int | GetCount () |
| 获取列表内容数量 更多...
|
|
void | Clear () |
| 清空列表 更多...
|
|
void | ShowDropdown (bool enable) |
| 显示列表 更多...
|
|
bool | IsSelChanged () |
| 判断选择项是否变化 更多...
|
|
bool | IsEdited () |
| 判断是否被编辑 更多...
|
|
| SysControlBase () |
|
virtual | ~SysControlBase () |
|
void | UpdateRect (RECT rctOld) override |
| 响应更新区域消息 更多...
|
|
HWND | Create (HWND hParent, RECT rct, std::wstring strText=L"") |
|
HWND | Create (HWND hParent, int x, int y, int w, int h, std::wstring strText=L"") |
|
void | Remove () |
| 移除控件 更多...
|
|
HWND | GetHandle () const |
|
SysControlType | GetControlType () const |
| 获取此控件类型 更多...
|
|
bool | IsEnable () |
|
void | Enable (bool enable) |
|
bool | IsVisible () |
|
void | Show (bool show) |
|
bool | IsFocused () |
|
void | SetFocus (bool focused) |
|
int | GetTextLength () |
|
std::wstring | GetText () |
|
void | SetText (std::wstring wstr) |
|
HFONT | GetFont () |
|
void | SetFont (int h, int w=0, std::wstring typeface=L"") |
|
int | GetID () |
|
| Container () |
|
virtual | ~Container () |
|
RECT | GetRect () const |
|
void | SetRect (int x, int y, int w, int h) |
| 设置位置和宽高 更多...
|
|
void | SetRect (RECT rct) |
| 设置矩形区域 更多...
|
|
POINT | GetPos () const |
|
int | GetX () const |
|
int | GetY () const |
|
void | SetPos (int x, int y) |
|
void | SetPos (POINT pt) |
|
void | Move (int x, int y) |
|
void | MoveRel (int dx, int dy) |
|
int | GetWidth () const |
|
void | SetWidth (int w) |
|
int | GetHeight () const |
|
void | SetHeight (int h) |
|
void | Resize (int w, int h) |
|
|
void | RealCreate (HWND hParent) override |
| 实际调用的创建控件函数(各种控件实现不同,但内部都调用 CreateControl 创建控件) 更多...
|
|
HWND | CreateControl (HWND hParent, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle) |
| 创建控件 更多...
|
|
系统组合框控件
在文件 SysComboBox.h 第 16 行定义.
◆ SysComboBox() [1/3]
HiEasyX::SysComboBox::SysComboBox |
( |
| ) |
|
◆ SysComboBox() [2/3]
HiEasyX::SysComboBox::SysComboBox |
( |
HWND |
hParent, |
|
|
RECT |
rct, |
|
|
std::wstring |
strText = L"" |
|
) |
| |
◆ SysComboBox() [3/3]
HiEasyX::SysComboBox::SysComboBox |
( |
HWND |
hParent, |
|
|
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h, |
|
|
std::wstring |
strText = L"" |
|
) |
| |
◆ AddString()
void HiEasyX::SysComboBox::AddString |
( |
std::wstring |
wstrText | ) |
|
◆ Clear()
void HiEasyX::SysComboBox::Clear |
( |
| ) |
|
◆ DeleteString()
void HiEasyX::SysComboBox::DeleteString |
( |
int |
index | ) |
|
◆ GetCount()
int HiEasyX::SysComboBox::GetCount |
( |
| ) |
|
◆ GetSel()
int HiEasyX::SysComboBox::GetSel |
( |
| ) |
const |
|
inline |
◆ InsertString()
void HiEasyX::SysComboBox::InsertString |
( |
int |
index, |
|
|
std::wstring |
wstrText |
|
) |
| |
◆ IsEdited()
bool HiEasyX::SysComboBox::IsEdited |
( |
| ) |
|
◆ IsSelChanged()
bool HiEasyX::SysComboBox::IsSelChanged |
( |
| ) |
|
判断选择项是否变化
在文件 SysComboBox.cpp 第 152 行定义.
154 bool r = m_bSelChanged;
155 m_bSelChanged =
false;
◆ PreSetStyle()
void HiEasyX::SysComboBox::PreSetStyle |
( |
PreStyle |
pre_style | ) |
|
在创建控件前预设样式
在文件 SysComboBox.cpp 第 39 行定义.
41 if (pre_style.always_show_list)
43 m_lBasicStyle |= CBS_SIMPLE;
44 m_lBasicStyle &= ~CBS_DROPDOWN;
45 if (!pre_style.editable)
46 m_bSimple_No_Edit =
true;
50 if (pre_style.editable)
52 m_lBasicStyle |= CBS_DROPDOWN;
56 m_lBasicStyle |= CBS_DROPDOWNLIST;
61 m_lBasicStyle |= CBS_SORT;
63 m_lBasicStyle &= ~CBS_SORT;
◆ RealCreate()
void HiEasyX::SysComboBox::RealCreate |
( |
HWND |
hParent | ) |
|
|
overrideprotectedvirtual |
实际调用的创建控件函数(各种控件实现不同,但内部都调用 CreateControl 创建控件)
- 参数
-
实现了 HiEasyX::SysControlBase.
在文件 SysComboBox.cpp 第 5 行定义.
17 if (m_bSimple_No_Edit)
20 HWND combobox_edit = ChildWindowFromPoint(
GetHandle(), { 3,3 });
21 Edit_SetReadOnly(combobox_edit,
true);
◆ RegisterEditMessage()
void HiEasyX::SysComboBox::RegisterEditMessage |
( |
void(*)(std::wstring wstrText) |
pFunc | ) |
|
◆ RegisterSelMessage()
void HiEasyX::SysComboBox::RegisterSelMessage |
( |
void(*)(int sel, std::wstring wstrSelText) |
pFunc | ) |
|
◆ SelectString()
bool HiEasyX::SysComboBox::SelectString |
( |
std::wstring |
wstrText | ) |
|
◆ SetSel()
void HiEasyX::SysComboBox::SetSel |
( |
int |
sel | ) |
|
◆ ShowDropdown()
void HiEasyX::SysComboBox::ShowDropdown |
( |
bool |
enable | ) |
|
◆ UpdateMessage()
LRESULT HiEasyX::SysComboBox::UpdateMessage |
( |
UINT |
msg, |
|
|
WPARAM |
wParam, |
|
|
LPARAM |
lParam, |
|
|
bool & |
bRet |
|
) |
| |
|
overridevirtual |
更新消息,此函数无需用户调用
- 参数
-
[in] | msg | 新消息 |
[in] | wParam | 参数 |
[in] | lParam | 参数 |
[out] | bRet | 标记是否返回值 |
- 返回
- 不定返回值
重载 HiEasyX::SysControlBase .
在文件 SysComboBox.cpp 第 66 行定义.
68 if (msg == WM_COMMAND)
70 if (LOWORD(wParam) ==
GetID())
72 switch (HIWORD(wParam))
79 int len = ComboBox_GetLBTextLen(
GetHandle(), m_nSel);
80 WCHAR* buf =
new WCHAR[len + 1];
81 ZeroMemory(buf, (len + 1) *
sizeof WCHAR);
82 ComboBox_GetLBText(
GetHandle(), m_nSel, buf);
83 m_pFuncSel(m_nSel, buf);
该类的文档由以下文件生成: