Centering Wizard?

This is a discussion on Centering Wizard? within the Windows Programming forums, part of the Platform Specific Boards category; Hey guys! I'm back with yet another problem. I have created an install wizard using Win32 API Property Sheets. As ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    13

    Centering Wizard?

    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. I have attached a screen shot to show what's happening.

    Thank you for all of your help in advance!

    Joe

    Edit: You can view the image here but be forewarned that it is in 800x600 at high resolution.
    Last edited by JoeCoder; 01-19-2004 at 02:01 AM.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    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.

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    Post your centering code if still doesn't work.

    gg

  4. #4
    Registered User
    Join Date
    Dec 2003
    Posts
    13
    No dice. I added the code below as suggested by knutso (thanks!) but it did not work!

    Code:
    GetClientRect(GetParent(hdlg), &rc);
    MoveWindow(hdlg, (rc.right/2)-(200/2),(rc.bottom/2)-(140/2),200,140,TRUE);

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    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.

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    In the picture the dialog does not look like a WM_CHILD window.

  7. #7
    Registered User
    Join Date
    Dec 2003
    Posts
    13
    All of the dialogs have been created with the "WS_CHILD" style. Also, the code has been placed in each dialog's "WM_INITDIALOG".

  8. #8
    Registered User
    Join Date
    Dec 2003
    Posts
    13
    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!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-26-2007, 06:18 AM
  2. Making a wizard w/ Win32 API?
    By JoeCoder in forum Windows Programming
    Replies: 10
    Last Post: 12-10-2003, 09:56 PM
  3. How Could I Make My Own Wizard in MFC?
    By WiKiDJeFF in forum C++ Programming
    Replies: 2
    Last Post: 05-05-2003, 06:25 PM
  4. VC++6.0 Add member function Wizard
    By 7stud in forum C++ Programming
    Replies: 5
    Last Post: 04-05-2003, 07:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21