-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl.cpp
More file actions
142 lines (108 loc) · 2.23 KB
/
Control.cpp
File metadata and controls
142 lines (108 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Control.cpp: implementation of the Control class.
//
//////////////////////////////////////////////////////////////////////
#include "Control.h"
#include <string.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Control::Control()
{
this->hWnd = NULL;
this->hParent = NULL;
this->dwId = 0;
this->lpTag = NULL;
this->strControlClass = "Control";
this->strTitle = "Title";
this->dwStyle = WS_CHILD | WS_VISIBLE;
this->dwExStyle = WS_EX_WINDOWEDGE;
}
Control::~Control()
{
}
VOID Control::SetParent(HWND hParent)
{
::SetParent(this->hWnd, hParent);
}
HWND Control::GetParent()
{
return ::GetParent(this->hWnd);
}
VOID Control::Size(UINT uWidth, UINT uHeight)
{
::SetWindowPos(this->hWnd, NULL, 0, 0, uWidth, uHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
VOID Control::Move(UINT uX, UINT uY)
{
::SetWindowPos(this->hWnd, NULL, uX, uY, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
UINT Control::XPosition()
{
RECT rc;
::GetClientRect(this->hWnd, &rc);
return rc.left;
}
UINT Control::YPosition()
{
RECT rc;
::GetClientRect(this->hWnd, &rc);
return rc.top;
}
UINT Control::Width()
{
RECT rc;
::GetClientRect(this->hWnd, &rc);
return (rc.right - rc.left);
}
UINT Control::Height()
{
RECT rc;
::GetClientRect(this->hWnd, &rc);
return (rc.bottom - rc.top);
}
VOID Control::Kill()
{
::DestroyWindow(this->hWnd);
}
VOID Control::Show()
{
::ShowWindow(this->hWnd, SW_SHOW);
}
VOID Control::Hide()
{
::ShowWindow(this->hWnd, SW_HIDE);
}
VOID Control::Enable()
{
::EnableWindow(this->hWnd, TRUE);
}
VOID Control::Disable()
{
::EnableWindow(this->hWnd, FALSE);
}
VOID Control::SetTag(LPVOID tag)
{
this->lpTag = tag;
}
LPVOID Control::GetTag()
{
return this->lpTag;
}
VOID Control::SetTitle(LPTSTR title)
{
this->strTitle = title;
::SetWindowText(this->hWnd, this->strTitle);
}
LPTSTR Control::GetTitle()
{
::GetWindowText(this->hWnd, this->strTitle, MAX_TITLE);
return this->strTitle;
}
VOID Control::SetFont(HFONT font)
{
::SendMessage(this->hWnd, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));
}
HFONT Control::GetFont()
{
return (HFONT)SendMessage(this->hWnd, WM_GETFONT, 0, 0);
}