Archived

This topic is now archived and is closed to further replies.

Resizing windows and scrollbars

This topic is 4957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

		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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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().


Thanks Salsa!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

Share this post


Link to post
Share on other sites
quote:
Original post by Invader X

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().



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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites