Window resizeing wrong

This is a discussion on Window resizeing wrong within the Windows Programming forums, part of the Platform Specific Boards category; Ok, the problem is say I create a window at 800x600, but the window ends up a different size (Window ...

  1. #1
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630

    Window resizeing wrong

    Ok, the problem is say I create a window at 800x600, but the window ends up a different size (Window cannot be sized by a user). Using WM_SIZE to get the updated sizes for the window class I find that the width and height of the window have shrunk! Usually by 10-20 on both, in the above example something like 792x573 or something like that. Now the problem, the application supports fulscren mode using the default window size of 800x600 but since the values have changed the call to DisplayMode fails since there is no 792x573. The values for the window size stay 800x600 untill WM_SIZE when they get corrupted, after debugging im lost, since the only WM_SIZE called is from the CreateWindowEx call.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    WM_SIZE provides the client dimension (like GetClientRect does); CreateWindowEx supplies window dimensions ie. client + borders, menu dimensions etc (the height and width would be same as generated by GetWindowRect). If the only window style is WS_POPUP then window and client dimesions will be the same, since there's no border etc. AdjustWindowRectEx (and AdjustWindowRect) allows you to calculate window size based on desired client size. Or you can query border etc dimensions from GetSystemMetrics and do the conversions based on client or window size for yourself.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Thanks Ken, maybe you can help me with the next problem, when using WS_OVERLAPPED window everything renders fine (GL) but if specifying WS_POPUP nothing renders. Ive been debugging and find right after RegisterClassEx an error code of 2 is returned (system cannot find the specified file) , I dont know why it says that since right now im only loading the default mouse cursor and it does. Next it gives me an error of 127 (the specified procedure can not be found) if I check an error during WM_CREATE before and after doing anything in the message processing. After returning from window creation (call from CreateWindowEx returns) I get the error 1400 (Invalid window handle) but the hWnd, hInstance are both valid (only with WS_POPUP otherwise still 127). Heres a link to the code if you dont mind looking through it. GLWindow


    Edit:
    I striped out the GL stuff and created an app using the base class CBWindow and still get the 2 and 127 errors. Heres the striped version Stripped Version
    Last edited by xds4lx; 12-19-2005 at 10:07 PM.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  4. #4
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    After doing a lot of searching I found that GetLastError will return 2 if called after a successful call to RegisterClassEx and I should only check it if the value returned by registering is 0. So im asuming the same is with 127 being returned after CreateWindowEx is called. Ive uploaded a newer version of the code but still cant see why nothing is rendered if I simply the style to WS_POPUP (tried changing some demos to use WS_POPUP in window mode and they work).
    GLWindow
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Your GLWindow::ResizeWindow member function is only called in response to a WM_SIZE event, an event which a window with only WS_POPUP as a window style never receives. This means that the viewport and perspective are never set - a call to GLWindow::ResizeWindow in your GLWindow::Create function, after the call to Initialize with suitable width and height (GetClientRect), will remedy this.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Ken you are a God!!!! Tired eyes never find the problem.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 07:57 PM
  2. internet
    By yeah in forum C Programming
    Replies: 16
    Last Post: 02-12-2005, 10:37 PM
  3. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM
  5. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 05:49 PM

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