系统控件基础
更多...
#include <SysControlBase.h>
|
| SysControlBase () |
|
virtual | ~SysControlBase () |
|
void | UpdateRect (RECT rctOld) override |
| 响应更新区域消息 更多...
|
|
virtual LRESULT | UpdateMessage (UINT msg, WPARAM wParam, LPARAM lParam, bool &bRet) |
| 更新消息,此函数无需用户调用 更多...
|
|
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) |
|
|
HWND | CreateControl (HWND hParent, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle) |
| 创建控件 更多...
|
|
virtual void | RealCreate (HWND hParent)=0 |
| 实际调用的创建控件函数(各种控件实现不同,但内部都调用 CreateControl 创建控件) 更多...
|
|
系统控件基础
在文件 SysControlBase.h 第 35 行定义.
◆ SysControlBase()
HiEasyX::SysControlBase::SysControlBase |
( |
| ) |
|
◆ ~SysControlBase()
HiEasyX::SysControlBase::~SysControlBase |
( |
| ) |
|
|
virtual |
◆ Create() [1/2]
HWND HiEasyX::SysControlBase::Create |
( |
HWND |
hParent, |
|
|
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h, |
|
|
std::wstring |
strText = L"" |
|
) |
| |
◆ Create() [2/2]
HWND HiEasyX::SysControlBase::Create |
( |
HWND |
hParent, |
|
|
RECT |
rct, |
|
|
std::wstring |
strText = L"" |
|
) |
| |
创建控件(从控件对象创建出 UI 实体)
注意:
同一个控件对象不能反复创建 UI 实体
- 参数
-
[in] | hParent | 父窗口句柄 |
[in] | rct | 控件区域 |
[in] | strText | 控件文本 |
- 返回
- 控件窗口句柄
在文件 SysControlBase.cpp 第 58 行定义.
◆ CreateControl()
HWND HiEasyX::SysControlBase::CreateControl |
( |
HWND |
hParent, |
|
|
LPCTSTR |
lpszClassName, |
|
|
LPCTSTR |
lpszWindowName, |
|
|
DWORD |
dwStyle |
|
) |
| |
|
protected |
创建控件
- 参数
-
[in] | hParent | 父控件 |
[in] | lpszClassName | 窗口类名 |
[in] | lpszWindowName | 窗口名 |
[in] | dwStyle | 窗口样式 |
- 返回
- 窗口句柄
在文件 SysControlBase.cpp 第 17 行定义.
25 c.hMenu = (HMENU)(
long long)
GetID();
26 c.hwndParent = hParent;
32 c.lpszName = lpszWindowName;
33 c.lpszClass = lpszClassName;
◆ Enable()
void HiEasyX::SysControlBase::Enable |
( |
bool |
enable | ) |
|
◆ GetControlType()
◆ GetFont()
HFONT HiEasyX::SysControlBase::GetFont |
( |
| ) |
|
◆ GetHandle()
HWND HiEasyX::SysControlBase::GetHandle |
( |
| ) |
const |
|
inline |
◆ GetID()
int HiEasyX::SysControlBase::GetID |
( |
| ) |
|
◆ GetText()
std::wstring HiEasyX::SysControlBase::GetText |
( |
| ) |
|
在文件 SysControlBase.cpp 第 126 行定义.
129 WCHAR* buf =
new WCHAR[len + 1];
130 ZeroMemory(buf,
sizeof WCHAR * (len + 1));
131 GetWindowText(
GetHandle(), buf, len + 1);
132 std::wstring str = buf;
◆ GetTextLength()
int HiEasyX::SysControlBase::GetTextLength |
( |
| ) |
|
◆ IsEnable()
bool HiEasyX::SysControlBase::IsEnable |
( |
| ) |
|
◆ IsFocused()
bool HiEasyX::SysControlBase::IsFocused |
( |
| ) |
|
在文件 SysControlBase.cpp 第 106 行定义.
108 DWORD SelfThreadId = GetCurrentThreadId();
109 DWORD ForeThreadId = GetWindowThreadProcessId(
m_hParent, NULL);
110 AttachThreadInput(ForeThreadId, SelfThreadId,
true);
111 HWND hWnd = GetFocus();
112 AttachThreadInput(ForeThreadId, SelfThreadId,
false);
◆ IsVisible()
bool HiEasyX::SysControlBase::IsVisible |
( |
| ) |
|
◆ RealCreate()
virtual void HiEasyX::SysControlBase::RealCreate |
( |
HWND |
hParent | ) |
|
|
protectedpure virtual |
◆ Remove()
void HiEasyX::SysControlBase::Remove |
( |
| ) |
|
◆ SetFocus()
void HiEasyX::SysControlBase::SetFocus |
( |
bool |
focused | ) |
|
◆ SetFont()
void HiEasyX::SysControlBase::SetFont |
( |
int |
h, |
|
|
int |
w = 0 , |
|
|
std::wstring |
typeface = L"" |
|
) |
| |
在文件 SysControlBase.cpp 第 147 行定义.
154 m_hFont = CreateFont(
161 DEFAULT_PITCH | FF_MODERN,
164 SendMessage(
GetHandle(), WM_SETFONT, (WPARAM)m_hFont, 0);
165 InvalidateRect(
GetHandle(),
nullptr,
true);
◆ SetText()
void HiEasyX::SysControlBase::SetText |
( |
std::wstring |
wstr | ) |
|
◆ Show()
void HiEasyX::SysControlBase::Show |
( |
bool |
show | ) |
|
◆ UpdateMessage()
LRESULT HiEasyX::SysControlBase::UpdateMessage |
( |
UINT |
msg, |
|
|
WPARAM |
wParam, |
|
|
LPARAM |
lParam, |
|
|
bool & |
bRet |
|
) |
| |
|
virtual |
◆ UpdateRect()
void HiEasyX::SysControlBase::UpdateRect |
( |
RECT |
rctOld | ) |
|
|
overridevirtual |
◆ m_hParent
HWND HiEasyX::SysControlBase::m_hParent = nullptr |
|
protected |
◆ m_hWnd
HWND HiEasyX::SysControlBase::m_hWnd = nullptr |
|
protected |
◆ m_nID
int HiEasyX::SysControlBase::m_nID = 0 |
|
protected |
◆ m_type
该类的文档由以下文件生成: