case WM_SIZE:
RECT rt3;
GetClientRect(hWnd,&rt3);
MoveWindow(hscroll,rt3.right-18,30,18,rt3.bottom-50,true);
break;
How come this code doesn't move my scrollbar when I resize my window? It should be moving the scrollbar so its on the right-side of the window, but it just stays at its initial position and doesn't move.
I'm obviously doing something wrong?
Thakns
[edited by - Xtremehobo on May 18, 2004 10:59:24 PM]
Resizing windows and scrollbars
cookie to anybody who can tell me how to move and resize my scrollbar when the window is resised?
Is this scrollbar a scrollbar you created?
Is hscroll a valid HWND?
Does MoveWindow succeed? If not, what''s the return of GetLastError()?
Is hscroll a valid HWND?
Does MoveWindow succeed? If not, what''s the return of GetLastError()?
MoveWindow returns 1 (true?) but GetLastError returns 6 (invalid handle).
If I change the number subtracted from the x-position in MoveWindow, however, it does change the position of the scrollbar.
If I change the number subtracted from the x-position in MoveWindow, however, it does change the position of the scrollbar.
I am unsure if the client rect as already been modified when WM_SIZE is sent, I suspect it has but in either case GetClientRect() is unnecessary.
I would try using those values instead of those returned by GetClientRect().
Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
quote:
lParam
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
I would try using those values instead of those returned by GetClientRect().
Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
quote:Original post by Invader Xquote:
lParam
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
I would try using those values instead of those returned by GetClientRect().
Tried it, still doesn''t work
Something that I have noticed though is it WILL set the correct position the FIRST time my window receives WM_SIZE but it''ll only position the scrollbar once and it''ll never work again after that.
I just tried that snippet, it works fine. Almost.
The first WM_SIZE you receive will be BEFORE the childs are even created. That MoveWindow might try to move a non-existant window. That won''t be too bad, but it''s a mistake. Before calling that MoveWindow check if the scrollbar has been created already.
The first WM_SIZE you receive will be BEFORE the childs are even created. That MoveWindow might try to move a non-existant window. That won''t be too bad, but it''s a mistake. Before calling that MoveWindow check if the scrollbar has been created already.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement