Resizing windows and scrollbars

Started by
6 comments, last by Xtremehobo 19 years, 11 months ago

		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]
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
Advertisement
cookie to anybody who can tell me how to move and resize my scrollbar when the window is resised?

pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
Is this scrollbar a scrollbar you created?

Is hscroll a valid HWND?

Does MoveWindow succeed? If not, what''s the return of GetLastError()?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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.
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
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
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.
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Weirddd... The snippet works if I stick it in a more simple app, but won''t work when I have it in my main app :-\
pixelwrench.com | [email="matt[nospam]@pixelwrench[nospam]com"]email[/email] lethalhamster: gamedev keeps taking my money, but im too lazy to not let them

This topic is closed to new replies.

Advertisement