c++ - Get needed printer dialog window view - Stack Overflow

option (1):option (2):I want to open printer dialog window. But I need first option (1). If I set hdwnOw

  1. option (1):

  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.

  1. option (1):

  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
Add a comment  | 

1 Answer 1

Reset to default 0

You 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).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745094075a4610867.html

相关推荐

  • c++ - Get needed printer dialog window view - Stack Overflow

    option (1):option (2):I want to open printer dialog window. But I need first option (1). If I set hdwnOw

    19小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信