Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
None
-
Windows
-
f4ffe2a2439928992c3f44085e81686d4f911417 (dev, 3.3.2014, 5.4)
Description
That's the default configuration for dialogs in most Windows application, but it is not possible to achive that with any combintation of Qt::WindowFlags. Ie. setting only Qt::Dialog on a toplevel dialog with parent results in system icon, "what's this" and close button. OR'ing with Qt::WindowTitleHint removes everything, and adding any other flag also enables the unwanted system menu.
The following Win32 code creates a window with closing box and without system menu:
- Set the icon in the class struct to 0
- Use exStyle WS_EX_DLGMODALFRAME
- Use Style WS_POPUPWINDOW ( WS_POPUP | WS_BORDER | WS_SYSMENU [! although it does not show])
#include <windows.h> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = L"qtest"; wcex.hIconSm = NULL; ATOM windowClass = RegisterClassEx(&wcex); HWND hWnd = CreateWindowEx(WS_EX_DLGMODALFRAME, (TCHAR*)windowClass, L"Example", WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_DLGFRAME | WS_OVERLAPPED | WS_SIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 200, 100, 0, 0, hInstance, 0); if (!hWnd) return FALSE; SendMessage(hWnd, WM_SETICON, 0, 0); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); MSG msg; while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }
Attachments
Issue Links
- resulted in
-
QTBUG-45402 Dialog have header with Qt::Dialog | Qt::CustomizeWindowHint | Qt::MSWindowsFixedSizeDialogHint
- Closed
-
QTBUG-41162 REG [5.3.2-5.4] Dialog flag prevents WA_TranslucentBackground widgets to show up
- Closed