在Windows应用程序中,我正在使用CreateWindow()函数创建一个新窗口。注册和窗口创建如下:
// 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);
我继续使用该窗口并使用流式视频对其进行更新,该视频可以正常工作。但是,看来我作为CreateWindow()的dwStyle参数传递的所有内容都将被忽略。该窗口没有标题栏,最小化或最大化按钮,就像重叠窗口中所期望的那样。此外,窗口不会最大化。奇怪的是,将dwStyle更改为
WS_OVERLAPPEDWINDOW | WS_HSCROLL /* dwStyle */
现在,将鼠标悬停在窗口上时会显示左/右箭头,但没有实际的滚动条。有谁知道什么可能导致这种奇怪的行为?
最佳答案
绘制标题栏和其他类似的操作要求您将未处理的窗口消息传递给DefWindowProc
。例如,在WM_NCPAINT
消息期间会绘制标题栏。如果您没有将消息传递给DefWindowProc
,那将无法完成。