Log in

View Full Version : CreateWindowEx question


lakibuk
10-17-2003, 10:57 AM
I want to create a fullscreen window.
The window is always 648x511, no matter what height/width i use. It's 648x511 directly after creation.
width and height are set to the correct values.
So there seems to be a problem with this code:
Any ideas?

hWnd = CreateWindowEx(0,
NAME,
TITLE,
WS_OVERLAPPED|WS_MINIMIZEBOX|WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
width ,
height ,
NULL,
NULL,
hInstance,
NULL);

ggambett
10-17-2003, 11:29 AM
If by "correct values" you mean "640x480", I'd say the window is taking that as the client area size. The extra pixels would be explained by the window borders and the title bar.

I can be horribly wrong in this one, of course.

lakibuk
10-17-2003, 01:22 PM
I can specify 100x100 as size and get 648x511,too.
That's the problem.

Akura
10-17-2003, 02:06 PM
Try using

WS_OVERLAPPED|WS_MINIMIZEBOX|WS_SYSMENU | WS_VISIBLE

And don't use ShowWindow afterwards. Don't ask me why, but ShowWindow sometimes messes the window up.

lakibuk
10-17-2003, 02:11 PM
The problem is that the window is wrong directly after creation.
I call
if (hWnd) GetWindowRect(hWnd, &g_rcWindow);
after CreateWindowEx and it's already 648x511. That's before it's shown.

Larry Hastings
10-17-2003, 08:53 PM
It's a shot in the dark, but is the WM_CREATE handler resizing the window?

programmer_ted
10-17-2003, 09:06 PM
Basically what we're (they're) implying is that we need more info. Is there anything else you can tell us?

lakibuk
10-17-2003, 10:35 PM
@Larry - nice shot,thanks!
There was a WM_GETMINMAXINFO message that resized the window. Didn't think of that.

countzero
10-19-2003, 09:09 AM
The window size includes client size and frame size...
you have to caculate the window size youself, here is my code to to the simple math :

DWORD dwStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE;

// Calculate the proper size for the window given a client of 640x480
DWORD dwFrameWidth = GetSystemMetrics(SM_CXSIZEFRAME );
DWORD dwFrameHeight = GetSystemMetrics(SM_CYSIZEFRAME );
DWORD dwMenuHeight = 0;//GetSystemMetrics(SM_CYMENU );
DWORD dwCaptionHeight = GetSystemMetrics(SM_CYCAPTION );
DWORD dwWindowWidth = 640 + dwFrameWidth * 2;
DWORD dwWindowHeight = 480 + dwFrameHeight * 2 + dwMenuHeight + dwCaptionHeight;

// Create the render window
m_hWnd = CreateWindow(_T("D3D Window"),
m_strWindowTitle,
dwStyle,
CW_USEDEFAULT, CW_USEDEFAULT,
dwWindowWidth, dwWindowHeight,
0L,
NULL, //LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU) ),
hInst,
0L);