In my Windows application, I’m creating a new window using the CreateWindow() function. The registration and window creation are as follows:
// Set up the capture window
WNDCLASS wc = {0};
// Set which method handles messages passed to the window
wc.lpfnWndProc = WindowMessageRedirect<CStillCamera>;
// Make the instance of the window associated with the main application
wc.hInstance = GetModuleHandle(NULL);
// Set the cursor as the default arrow cursor
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
// Set the class name required for registering the window and identifying it for future
// CreateWindow() calls
wc.lpszClassName = c_wzCaptureClassName.c_str();
RegisterClass(&wc); /* Call succeeding */
HWND hWnd = CreateWindow(
c_wzCaptureClassName.c_str() /* lpClassName */,
c_wzCaptureWindowName.c_str() /* lpWindowName */,
WS_OVERLAPPEDWINDOW | WS_MAXIMIZE /* dwStyle */,
CW_USEDEFAULT /* x */,
CW_USEDEFAULT /* y */,
CW_USEDEFAULT /*nWidth */,
CW_USEDEFAULT /* nHeight */,
NULL /* hWndParent */,
NULL /* hMenu */,
GetModuleHandle(NULL) /* hInstance */,
this /* lpParam */
);
if (!hWnd)
{
return false;
}
ShowWindow(hWnd, SW_SHOWDEFAULT);
UpdateWindow(hWnd);
I go on to use the window and update it with streaming video, which works correctly. However, it seems that whatever I pass as the dwStyle parameter of CreateWindow() gets ignored. The window has no title bar, minimize, or maximize buttons as one would expect from an overlapped window. Also, the window isn’t maximized. Strangely enough, changing dwStyle to
WS_OVERLAPPEDWINDOW | WS_HSCROLL /* dwStyle */
now shows the double-sided left/right arrow when hovering over the window but with no actual scroll bars. Does anyone have any ideas what might be causing this strange behavior?
Drawing of the title bar and other such things requires that you pass unhandled window messages to
DefWindowProc. For example, the title bar is painted during theWM_NCPAINTmessage. If you don’t pass the message toDefWindowProcthat just doesn’t get done.