-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtoolbarDraw.cpp
125 lines (92 loc) · 3.03 KB
/
toolbarDraw.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
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
#include "headerui.h"
toolbarDraw::toolbarDraw():BaseWindow(),ImageListID(0)
{
dwStyle=WS_CHILD|WS_BORDER;
cx=cy=16;
flag=ILC_MASK|ILC_COLOR16;
cGrow=(int)NULL;
}
void toolbarDraw::setStyle(DWORD style)
{
dwStyle=style;
}
void toolbarDraw::setButtonSize(int sx,int sy)
{
cx=sx;
cy=sy;
}
int toolbarDraw::init( HWND hWndParent,
LPCTSTR windowName,
const int cInitial,
HBITMAP hBmpToolbar,
TBBUTTON *tbButtons
)
{
hWnd = CreateWindow(
TOOLBARCLASSNAME, // the window class name
windowName, // The window title
dwStyle, // Window style as overlapped
xPos, // Default screen position of upper left
yPos, // corner of our window as x,y...
width, // Default window size
height, // ....
hWndParent, // No parent window
NULL, // No menu
NULL, // Program Instance handle
0 // No window creation data
);
if (hWnd == NULL)
return 0;
hImageList = ImageList_Create(cx, cy,flag, cInitial, cGrow);
// Set the image list.
SendMessage(hWnd, TB_SETIMAGELIST,
(WPARAM)ImageListID,
(LPARAM)hImageList);
ImageList_Add(
hImageList,
hBmpToolbar,
NULL
);
// Add buttons.
SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
SendMessage(hWnd, TB_ADDBUTTONS,(WPARAM)cInitial,(LPARAM)tbButtons);
// Resize the toolbar, and then show it.
SendMessage(hWnd, TB_AUTOSIZE, 0, 0);
ShowWindow(hWnd, TRUE);
return TRUE;
}
int toolbarDraw::initSTD( HWND hWndParent,
LPCTSTR windowName,
const int cInitial,
TBBUTTON *tbButtons
)
{
hWnd = CreateWindow(
TOOLBARCLASSNAME, // the window class name
windowName, // The window title
dwStyle, // Window style as overlapped
xPos, // Default screen position of upper left
yPos, // corner of our window as x,y...
width, // Default window size
height, // ....
hWndParent, // No parent window
NULL, // No menu
NULL, // Program Instance handle
0 // No window creation data
);
if (hWnd == NULL)
return 0;
hImageList = ImageList_Create(cx, cy,flag, cInitial, cGrow);
// Set the image list.
SendMessage(hWnd, TB_SETIMAGELIST,
(WPARAM)ImageListID,
(LPARAM)hImageList);
SendMessage(hWnd, TB_LOADIMAGES, (WPARAM)IDB_STD_LARGE_COLOR, (LPARAM)HINST_COMMCTRL);
// Add buttons.
SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
SendMessage(hWnd, TB_ADDBUTTONS,(WPARAM)cInitial,(LPARAM)tbButtons);
// Resize the toolbar, and then show it.
SendMessage(hWnd, TB_AUTOSIZE, 0, 0);
ShowWindow(hWnd, TRUE);
return TRUE;
}