- option (1):
- option (2):
I want to open printer dialog window. But I need first option (1). If I set hdwnOwner to NULL then I get what I need but printer window is behind other windows. If I use pd.hwndOwner = GetForegroundWindow(); then I get second option (2) which I don't need. So the question: how to have parent for printer window (it to be on top) and this printer window have the proper view (option 1) ? The code I use:
#include "commdlg.h"
static PRINTDLG pd;
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_NOWARNING | PD_RETURNDC | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
pd.hwndOwner = GetForegroundWindow();
int ok = PrintDlg(&pd);
I tried what I posted and got option 2 result.
- option (1):
- option (2):
I want to open printer dialog window. But I need first option (1). If I set hdwnOwner to NULL then I get what I need but printer window is behind other windows. If I use pd.hwndOwner = GetForegroundWindow(); then I get second option (2) which I don't need. So the question: how to have parent for printer window (it to be on top) and this printer window have the proper view (option 1) ? The code I use:
#include "commdlg.h"
static PRINTDLG pd;
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_NOWARNING | PD_RETURNDC | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
pd.hwndOwner = GetForegroundWindow();
int ok = PrintDlg(&pd);
I tried what I posted and got option 2 result.
Share Improve this question edited Mar 3 at 14:41 Thomas Weller 59.9k23 gold badges137 silver badges254 bronze badges asked Mar 3 at 12:42 SlavaSlava 111 bronze badge 2- 2 The real question is: why? What specific issue are you really trying to solve? – IInspectable Commented Mar 3 at 14:34
- Maybe you could check Thomas solution which uses SetWindowTheme. – Roy Li - MSFT Commented Mar 12 at 6:52
1 Answer
Reset to default 0You have enabled visual styles in your application. Thus the print dialog will adapt to that style. If you don't want the new style, don't enable it.
You could also disable is programmatically using SetWindowTheme():
#pragma comment(lib, "uxtheme.lib")
#include "uxtheme.h"
SetWindowTheme(GetForegroundWindow(), L" ", L" ");
If you do something like that, before you do the pull request, prepare yourself for a feedback meeting with your manager.
Note that this will not only change the look of the print dialog, but also the foreground window. It looks really Windows 3.1 and nobody wants that any more (IMHO; citation needed).