News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CreateWindowEx And Window Dimensions

Started by cman, October 27, 2010, 07:51:22 PM

Previous topic - Next topic

cman

Is a window created with "CreateWindowEx" the exact size as in width and height as the parameters entered or does the actual height and width include any frame or border the window is created with?  Is there a diagram available that shows the different parts of the window ( whats considered the borders or caption box , etc - I've forgotten whats what over the years  :red ) - I'm trying to write formulas for control placement on a window using " GetSystemMetrics" and I'm having trouble centering things and such. Thanks for any information!

MichaelW

At least normally, the values specified in the nWidth and nHeight parameters of CreateWindowEx are the dimensions of the bounding rectangle, the same dimensions returned by GetWindowRect.

There is an illustration of the components of a typical main window here:

http://msdn.microsoft.com/en-us/library/ms632597(v=VS.85).aspx#application

In case you are working with a dialog, the measurements are in dialog template units, not pixels:

http://msdn.microsoft.com/en-us/library/ms644994(VS.85).aspx#measurements


eschew obfuscation

cman

Ok, thanks for the information! I had another question though - is there a Windows Class Style that allows for a fixed size window? I don't remember if this can be done or not. Thanks for any information!

MichaelW

If by fixed size you mean a window that is not sizeable, I posted a (somewhat crude) demo that will allow you to experiment with window styles here:

http://www.masm32.com/board/index.php?topic=3797.msg28395#msg28395
eschew obfuscation

hutch--

cman,

Just learn to OR the styles available for CreateWindowEx. You can also alter characteristics by the extended style which is the first parameter for the function call.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Neil

Here is a snippet from my code I use to create a 800 X 600 window that cannot be resized.


Main proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD

      LOCAL wc:WNDCLASSEX
      LOCAL msg:MSG
      LOCAL hWnd:HWND

   mov   wc.cbSize,SIZEOF WNDCLASSEX
   mov   wc.style, CS_HREDRAW or CS_VREDRAW
   mov   wc.lpfnWndProc, OFFSET WndProc
   mov   wc.cbClsExtra,NULL
   mov   wc.cbWndExtra,NULL
   push  hInst
   pop   wc.hInstance
   mov   wc.hbrBackground,COLOR_BTNFACE+4
   mov   wc.lpszMenuName,OFFSET MenuName
   mov   wc.lpszClassName,OFFSET ClassName
   invoke LoadIcon,NULL,500
   mov   wc.hIcon,eax
   mov   wc.hIconSm,NULL
   invoke LoadCursor,NULL,IDC_ARROW
   mov   wc.hCursor,eax
   invoke RegisterClassEx, addr wc
   INVOKE CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,ADDR AppName,\
           WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE,\
           CW_USEDEFAULT,CW_USEDEFAULT,800,600,NULL,NULL,hInst,NULL
   mov  hWnd,eax
      DisplayMenu hWnd,600
      DisplayWindow hWnd,SW_SHOWNORMAL
      INVOKE UpdateWindow, hWnd

Tedd

The size you give to CreateWindowEx includes all borders (and the titlebar) - it's the full size of the window.
You can use AdjustWindowRectEx to get the required full window size to produce the required client-area size.

To stop window resizing, you can just unset the WS_THICKFRAME style (and probably WS_MAXIMIZEBOX too)
= "WS_OVERLAPPEDWINDOW and not (WS_THICKFRAME or WS_MAXIMIZEBOX)"
No snowflake in an avalanche feels responsible.

cman

Thanks for the information! My Window has a bitmap painted on it which I intend to animate but every time the window is covered by another a portion of the bitmap is erased. I thought the "WM_PAINT" message handler in the window's WndProc function would handle this situation but doesn't. Do I need to invalidate the rectangle containing the bitmap between animation updates or is this a problem with my message handler or the style of window that I am using? Thanks for any information!