在我的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 */现在,当鼠标悬停在窗口上但没有实际滚动条时,会显示双侧左/右箭头。有没有人知道是什么导致了这种奇怪的行为?
发布于 2011-06-29 09:18:09
绘制标题栏和其他类似内容需要将未经处理的窗口消息传递给DefWindowProc。例如,标题栏是在WM_NCPAINT消息期间绘制的。如果不将消息传递给DefWindowProc,就无法完成任务。
发布于 2011-06-29 09:09:47
来自Microsoft Documentation中的注释
根据创建进程时在STARTUPINFO.dwFlags和STARTUPINFO.wShowWindow中指定的值,WS_MINIMIZE和WS_MAXIMIZE样式可能会被忽略。
必须使用WS_MINIMIZEBOX和WS_MAXIMIZEBOX显式启用最小化和最大化框。您可能需要WS_OVERLAPPEDWINDOW,而不仅仅是WS_OVERLAPPED;这将包括最小化和最大化框。
https://stackoverflow.com/questions/6514547
复制相似问题