views:

307

answers:

2

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.

+1  A: 

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.

Gordon Wilson
A: 

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
Mark Ransom