I am currently working on the Rebar control and met a little problem. The Rebar control seems to redraw itself all the time when I try to resize the window (and the control), which slow down everything.
But applications like IE and WinZip don't seem to have such problem. How do they do that?
Here is my code:
.IF (uMsg == WM_CREATE)
mov iccex.dwSize, SIZEOF INITCOMMONCONTROLSEX
mov iccex.dwICC, ICC_COOL_CLASSES or ICC_BAR_CLASSES
INVOKE InitCommonControlsEx, ADDR iccex
INVOKE CreateWindowEx, WS_EX_TOOLWINDOW, ADDR REBARCLASSNAME, NULL, \
WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_BORDER or \
CCS_NODIVIDER or CCS_NOPARENTALIGN or RBS_BANDBORDERS or RBS_VARHEIGHT, \
0, 0, 0, 0, hWin, NULL, hInstance, NULL
mov hReBar, eax
INVOKE CreateWindowEx, NULL, ADDR TOOLBARCLASSNAME, NULL, \
WS_CHILD or WS_VISIBLE or CCS_NOPARENTALIGN, 0, 0, 0, 0, \
hReBar, NULL, hInstance, NULL
mov hToolBar, eax
mov rbbi.cbSize, SIZEOF REBARBANDINFO
mov rbbi.fMask, RBBIM_SIZE or RBBIM_CHILD or RBBIM_CHILDSIZE or RBBIM_STYLE
mov rbbi.fStyle, RBBS_BREAK or RBBS_GRIPPERALWAYS
mov rbbi.cxMinChild, 0
INVOKE GetWindowRect, hToolBar, ADDR rc
mov eax, rc.bottom
sub eax, rc.top
mov rbbi.cyMinChild, eax
mov rbbi.lx, 250
push hToolBar
pop rbbi.hwndChild
INVOKE SendMessage, hReBar, RB_INSERTBAND, -1, ADDR rbbi
.ELSEIF (eax == WM_SIZE)
INVOKE GetWindowRect, hReBar, ADDR rc
mov eax, rc.bottom
sub eax, rc.top
movzx ecx, WORD PTR
INVOKE MoveWindow, hReBar, 0, 0, ecx, eax, FALSE
.ENDIF
edit: added code tags
Hiro
This message was edited by Hiroshimator, on 2/6/2001 7:52:22 AMI'm sorry, the eax above should be uMsg.
i.e. .ELSEIF (uMsg == WM_SIZE)
Do you have any other calls to WM_SIZE? For example, when I use the rebar I trap the WM_NOTIFY to tell if the rebar resized, so I can adjust other things.
The trouble is that could set off a near-infinate sequence, moving the main window moves a rebar, which calls WM_SIZE, which moves a rebar, which calls WM_SIZE, which moves a rebar, which calls WM_SIZE, which moves a rebar, which calls WM_SIZE....
You get the idea.
My solotion for this isn't elegant, but it's always worked. Make a global flag NoSize. Set it FALSE in WM_CREATE. The first thing WM_SIZE will do is check this flag, and if TRUE, skip the resize code.
Immediatly after that, set NoSize to TRUE. That way, any self-generated WM_SIZE messages gt ignored. Just before WM_SIZE is complete, re-set the flag.
This message was edited by Ernie, on 2/6/2001 11:47:42 AM
Thanks Ernie. I found out the problem was on the toolbar. Toolbar controls that are hosted by rebar controls must set CCS_NORESIZE and CCS_NOPARENTALIGN styles because the rebar control sizes and positions the toolbar.