Results 1 to 5 of 5

Thread: Center Win32 Window. ?

  1. #1

    Thread Starter
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411

    Question

    How Do You Center A Win32 Window ? I use borland c++, and do not use MFC, Pure API. Thanx. Please only reply if you really know how to center a win32 window. I'm sorry i had to post again, but somebody had replied to my other request thinking they knew and they really didn't. I mean no disrespect for the help offered by the other person, but i mean come on, if your gonna reply to someones question, at least by half sure and not just go out on a wimb. thanx

    AAG

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    RECT r, desk;
    GetWindowRect(hWnd, &r);
    GetWindowRect(GetDesktopWindow(), &desk);
    
    int wa,ha,wb,hb;
    
    wa = (r.right - r.left) / 2;
    ha = (r.bottom - r.top) / 2;
    
    wb = (desk.right - desk.left) / 2;
    hb = (desk.bottom - desk.top) / 2;
    
    SetWindowPos(hWnd, wb - wa, hb - ha, wa*2, ha*2);
    I'm sure there are better ways...but I couldn't find anything automatic...I'm sure you can tidy this up a bit. It's not been tested, BTW
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I remember using somehting like WS_CENTERED....it is almost that...I'll look around for it.

  4. #4
    Guest
    I checked in MSDN and it was unlisted.

  5. #5
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Yeah I could have sworn I saw it somewhere but can't find it...I guess there isn't any

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width