-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.cpp
73 lines (59 loc) · 1.67 KB
/
Button.cpp
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
#include "Button.hpp"
void Button::create(UINT style, HWND hwnd, HINSTANCE instance, UINT callBackID, int x, int y, int width, int height)
{
/* style -> pour pouvoir rajouter BS_ICON ou BS_BITMAP */
m_hwndButton = CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_MULTILINE | BS_PUSHBUTTON | style,
x, y, width, height, hwnd, (HMENU)callBackID, instance, NULL);
}
LRESULT Button::setImage(WPARAM imgType, LPARAM hImage)
{
return SendMessage(m_hwndButton, BM_SETIMAGE, imgType, hImage);
}
LRESULT Button::setIco(LPARAM hImage)
{
return SendMessage(m_hwndButton, WM_SETICON, ICON_BIG, hImage);
}
void Button::setText(LPCTSTR text)
{
SetWindowText(m_hwndButton, text);
}
LRESULT Button::setFont(HFONT font)
{
// lParam -> true pour redessiner le bouton, pour que la nouvelle police s'applique
return SendMessage(m_hwndButton, WM_SETFONT,(WPARAM)font, MAKELPARAM(true, 0));// Modifie la police
}
void Button::setFocus(bool focus)
{
if(focus)
SendMessage(m_hwndButton, WM_SETFOCUS, NULL, 0);
else
SendMessage(m_hwndButton, WM_KILLFOCUS, NULL, 0);
}
bool Button::move(int x, int y, int width, int height)
{
return MoveWindow(m_hwndButton, x, y, width, height, true);
}
LRESULT Button::getCheck()
{
return SendMessage(m_hwndButton, BM_GETCHECK, 0, 0);
}
bool Button::enable(bool enable)
{
return EnableWindow(m_hwndButton, enable);
}
LRESULT Button::clic()
{
return SendMessage(m_hwndButton, BM_CLICK, 0, 0);
}
void Button::show()
{
ShowWindow(m_hwndButton,SW_SHOW);
}
void Button::hide()
{
ShowWindow(m_hwndButton,SW_HIDE);
}
HWND Button::getHWNDButton()
{
return m_hwndButton;
}