CMZTECH.NET
  • Blog
  • Graphics
  • Virtual Reality
  • 3D Printing
  • Fun Stuff
    • furiosus tangeret solum vitrum >
      • A new friend
      • Chorazin
      • Curious1
      • MRGAMERESOURCES
  • Contact

Creating a Window with Specific Dimensions

When developing under Windows, when you create a window you pass in width and height.  These however include the border pixels of the window and so the renderable area you get back is smaller.  For one application I created it was important that my actual render-able area was exactly 1280*720. 

AdjustWindowRectEx function

The AdjustWindowRectEx function lets you determine the size of a window based on the needs for the renderable area which is exactly what is needed.

Example Code:

Here is a code snippet showing how this function can be used to create a renderable area of specified dimensions.

RECT windowRect = {0, 0, width,height}; // Define Our Window Coordinates
DWORD windowStyle = WS_OVERLAPPEDWINDOW; // Define Our Window Style
DWORD windowExtendedStyle = WS_EX_APPWINDOW; // Define The Window's Extended Style
AdjustWindowRectEx (&windowRect, windowStyle, 0, windowExtendedStyle);


hwnd = CreateWindowEx(
        NULL,
        WndClassName,
        L"EnGiNe 1",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        windowRect.right-windowRect.left,
        windowRect.bottom-windowRect.top,
        NULL,
        NULL,
        hInstance,
        NULL
        );