-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebar.cpp
161 lines (147 loc) · 4.13 KB
/
rebar.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "mywindow.h"
#include "toolbar.h"
#include "rebar.h"
Rebar::Rebar(HWND hPrtWin,int height)
{
_height = height;
_hPrtWin = hPrtWin;
_hwndRebar = NULL;
}
Rebar::~Rebar()
{};
void Rebar::AppendChildToNewBand(HWND hchild,LPSTR textstr,UINT mask,UINT style,int cxmin,int cymin,int cymax,int cx)
{
REBARBANDINFO rbbi;
ZeroMemory(&rbbi, sizeof(rbbi));
rbbi.cbSize = sizeof(REBARBANDINFO);
// rbbi.fMask = RBBIM_COLORS|RBBIM_BACKGROUND|RBBIM_STYLE|RBBIM_CHILD|
// RBBIM_TEXT|RBBIM_SIZE|RBBIM_CHILDSIZE;
// rbbi.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS;
rbbi.fMask = mask;
rbbi.fStyle = style;
rbbi.lpText = textstr;
rbbi.hwndChild = hchild;
rbbi.cxMinChild = cxmin;
rbbi.cyMinChild = cymin;
rbbi.cyMaxChild = cymax;
rbbi.cx = cx;
rbbi.clrBack = RGB(166,202,240);
rbbi.clrFore = RGB(0,0,0);
// Add the band that has the toolbar.
SendMessage(_hwndRebar,RB_INSERTBAND,-1,(LPARAM)&rbbi);
};
// void Rebar::AppendChildToNewBand(HWND hchild,LPSTR textstr)
// {
// RECT rc;
// REBARBANDINFO rbbi;
// ZeroMemory(&rbbi, sizeof(rbbi));
//
// GetWindowRect(hchild,&rc);
//
// rbbi.cbSize = sizeof(REBARBANDINFO);
// rbbi.fMask = RBBIM_COLORS|RBBIM_BACKGROUND|RBBIM_STYLE|RBBIM_CHILD|
// RBBIM_TEXT|RBBIM_SIZE|RBBIM_CHILDSIZE;
// rbbi.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS;
// rbbi.lpText = textstr;
// rbbi.hwndChild = hchild;
// rbbi.cxMinChild = rc.right - rc.left;
// rbbi.cyMinChild = _height;
// rbbi.cx = 200;
// rbbi.clrBack = RGB(166,202,240);
// rbbi.clrFore = RGB(0,0,0);
//
// // Add the band that has the toolbar.
// SendMessage(_hwndRebar,RB_INSERTBAND,-1,(LPARAM)&rbbi);
// }
HWND Rebar::CreateReabar()
{
INITCOMMONCONTROLSEX icex;
RECT rc;
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(_hPrtWin,GWL_HINSTANCE);
GetClientRect(_hPrtWin, &rc);
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_COOL_CLASSES|ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
_hwndRebar = CreateWindowEx(WS_EX_TOOLWINDOW,
REBARCLASSNAME,
NULL,
WS_CHILD|WS_VISIBLE|RBS_VARHEIGHT|RBS_BANDBORDERS|CCS_NODIVIDER,
0,0,rc.right-rc.left,_height,
_hPrtWin,
NULL,
hInstance,
NULL);
if(!_hwndRebar)
{
return NULL;
}
return _hwndRebar;
}
HWND Rebar::CreateMenuInoReabar(int idmenu,WNDPROC MenuWinProc,bool ismaxwidth)
{
WNDCLASSEX wcmenu;
MENUBARINFO mbri;
int xMenu,yMenu,xFirstMenubar,itemcount;
HINSTANCE hinstance ;
if(!_hwndRebar)
return NULL;
hinstance = (HINSTANCE)GetWindowLong(_hPrtWin,GWL_HINSTANCE);
wcmenu.cbSize = sizeof(WNDCLASSEX);
wcmenu.style = 0;
wcmenu.lpfnWndProc = MenuWinProc;
wcmenu.cbClsExtra = 0;
wcmenu.cbWndExtra = 0;
wcmenu.hInstance = hinstance;
wcmenu.hIcon = 0;
wcmenu.hCursor = 0;
wcmenu.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcmenu.lpszMenuName = NULL;
wcmenu.lpszClassName = "MenuWindow";
wcmenu.hIconSm = 0;
RegisterClassEx(&wcmenu);
HWND hMenuWin = CreateWindowEx(0,
"MenuWindow",
NULL,WS_POPUP,
0,0,200,50,
_hPrtWin,
LoadMenu(hinstance,MAKEINTRESOURCE(idmenu)),
hinstance,
NULL);
ShowWindow(hMenuWin,SW_SHOW);
HMENU hmenu = GetMenu(hMenuWin);
mbri.cbSize = sizeof(MENUBARINFO);
itemcount = GetMenuItemCount(hmenu);
xMenu = 0;
for (int i=1; i<=itemcount; i++)
{
GetMenuBarInfo(hMenuWin,OBJID_MENU,1,&mbri);
if ( 1==i )
{
xFirstMenubar = mbri.rcBar.right - mbri.rcBar.left;
yMenu = mbri.rcBar.bottom - mbri.rcBar.top;
}
xMenu += mbri.rcBar.right - mbri.rcBar.left;
}
if (ismaxwidth)
{
xFirstMenubar = xMenu;
}
AppendChildToNewBand(hMenuWin,NULL,
RBBIM_BACKGROUND|RBBIM_STYLE|RBBIM_CHILD|
RBBIM_TEXT|RBBIM_SIZE|RBBIM_CHILDSIZE,
RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS,
xFirstMenubar,yMenu,
yMenu,xMenu);
return hMenuWin;
}
void Rebar::MoveRebar()
{
RECT rc;
PToolBar ptoobar = NULL;
GetClientRect(_hPrtWin, &rc);
if(_hwndRebar)
{
SetWindowPos(_hwndRebar,NULL,0,0,rc.right-rc.top,
_height,SWP_NOMOVE|SWP_NOZORDER);
}
}