Hey guys! I'm back with yet another problem. I have created an install wizard using Win32 API Property Sheets. As a parent, I have also created a gradient window. Like most installers, I want my wizard to be placed in the center of that gradient window. I have tried acomplishing this several ways, including setting the x and y in the individual dialog resources and using a CenterWindow() function that I found posted here, but nothing seems to work! Instead, the window is placed at the top left. :mad: I have attached a screen shot to show what's happening.
Thank you for all of your help in advance!
Edit: You can view the image here but be forewarned that it is in 800x600 at high resolution.
Just use GetClientRect(hwndParent, &r1) in the child window's WM_INITIALIZE.
Take the rect of the parent, and then use MoveWindow() to move the window to the following position:
left: (r1.right/2)-(childwindow's width/2)
top: (r1.bottom/2)-(childwindow's height/2)
I guess the child window has fixed width, if not you'll have to use the GetClientRect() on this window as well.
Post your centering code if still doesn't work.
No dice. :( I added the code below as suggested by knutso (thanks!) but it did not work! :mad:
Where is the code placed?
Is the window resized anywhere else in the code?
Is the window handle valid?
Is the window's parent set?
If everything is correct, the code should work...Try to watch the values of rc after GetClientRect() is ran.
In the picture the dialog does not look like a WM_CHILD window.
All of the dialogs have been created with the "WS_CHILD" style. Also, the code has been placed in each dialog's "WM_INITDIALOG".
Well, I have come up with a better way to create a wizard that actually works. Property Sheets have their places and Wizards just isn't one of them! :mad: