How to programmatically force use of the old print dialog in Windows 11 22H2

Helg Green 5 Reputation points
2023-07-14T16:09:35.11+00:00

Please tell me how to programmatically force the use of the old print dialog in Windows 11 22H2 in C ++? For example, using the PrintDlgEx() and PrintDlg() functions also invokes a new print dialog instead of the old one. There is also a way to make an entry in the registry, but it is not suitable, because if the application crashes, it will not be possible to change the value back in the registry.

The problem with the new dialog is that it is incorrectly initialized: if the initial mode "print range" is selected, instead of the range for example "1-2" it is displayed simply "1-" without the last digit.

Note:

Using GetForegroundWindow() to get another application's window does not reproduce the issue. The window must be created by your application, then the print dialog will always be displayed in the new style. The problem only affects Windows 11 22H2, in earlier versions the print dialog is used in the old style.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,693 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Dave Milner 5 Reputation points
    2024-09-16T21:37:15.96+00:00

    Helg,

    I know it's a little late for you, but I recently had to correct the same problem. The "modern" print dialog has the big empty No Preview Available space that looks like the user is missing something.

    To get the older print dialog I used the PrintDlg function (instead of PrintDlgEx) that uses the PRINTDLG structure and not the PRINTDLGEX structure. I added the PD_ENABLEPRINTHOOK flag to the flags and created a dummy print hook function:

    UINT_PTR __stdcall DummyPrintHookProc (HWND unnamedParam1, UINT unnamedParam2, WPARAM unnamedParam3, LPARAM unnamedParam4) { return 0; }

    and put .lpfnPrintHook = &DummyPrintHookProc; to make sure the function is noticed.

    Adding the printer hook procedure prevented windows from using the new dialog, but just for that call. It did not change the settings for any other programs or any other call of the print dialog.

    1 person found this answer helpful.
    0 comments No comments

  2. MCB 0 Reputation points
    2023-07-17T16:05:18.5533333+00:00

    I have the same question

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.