Jump to content
  • Advertisement
Sign in to follow this  
brechtjah

MoveWindow() function

This topic is 3603 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

I do not understand why the following code returns 1, even though I see no change on the screen:
bool test;
test = MoveWindow((HWND)ID_static1, 0, 0, 800, 800, true);
I have searched all over Google for a solution, but the topics about MoveWindow() are all different. Please assist : - ) EDIT: recompiled it and now it returns 0.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by brechtjah
I do not understand why the following code returns 1, even though I see no change on the screen:

bool test;
test = MoveWindow((HWND)ID_static1, 0, 0, 800, 800, true);
It succeeds because (HWND)ID_static1 happens to evaluate to a valid window handle, but it's not the one you want - you should always be wary of casts, if you need one it's usually a sign that something isn't expected.
In this case, you want to use the GetDlgItem() function (Assuming you have a dialog with ID_static1 as an item on it). E.g.:
test = MoveWindow(GetDlgItem(hDlg, ID_static1), 0, 0, 800, 800, true);
Where hDlg is the handle to the parent dialog box.

Quote:
Original post by brechtjah
I have searched all over Google for a solution, but the topics about MoveWindow() are all different.
Please assist : - )
If in doubt, The MSDN is the most likely to be correct.

Share this post


Link to post
Share on other sites
Quote:
Original post by brechtjah
But I'm not using dialogs, it's a static control in my main window.
From the Documentation:
Quote:
You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window.
Or, just use the HWND from CreateWindow[Ex] directly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!