user23163
user23163

Reputation: 525

win32 C++ printing PRINTDLGEX not declared?

I am trying to figure out how to print in C++. I want to get the device context using the PrintDlgEx function, which needs a PRINTDLGEX structure. However, I cannot create a PRINTDLGEX because it says it's undeclared. I have included the Commdlg.h and Windows.h and linked the Comdlg32.lib, but all to no avail. Is there something I'm missing? I can go into the Commdlg header file and see that PRINTDLGEX is declared, but for some reason I can't use it? My operating system is Window Vista.

Upvotes: 0

Views: 1209

Answers (2)

Mark Ransom
Mark Ransom

Reputation: 308452

You need to declare your target Windows version to be modern enough to support the structure, the defaults assume something ancient. Typically this will be done in your stdafx.h file. These definitions must come before the include of the Windows header files.

#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0501

Upvotes: 0

Gordon Wilson
Gordon Wilson

Reputation: 26384

It's probably undeclared because it's within a #ifdef STDMETHOD block starting on line #878 of Commdlg.h

STDMETHOD is defined in basetyps.h

This post, Customizing PrintDlgEx and IPrintDialogCallback, might be useful as well.

Upvotes: 1

Related Questions