PrintDlgEx
-
Hi, I'm working on Windows 2000 and VC++ 6.0. I need to show the new print property sheet available in windows 2000 onwards. I found a class called CPrintDialogEx that could display it but unfortunately it is available only in VC 7.0. So I did the following to get the property sheet - I created a dialog based application. The following is in the .h file of the dialog class
typedef struct tagPRINTPAGERANGE {
DWORD nFromPage;
DWORD nToPage;
} PRINTPAGERANGE, *LPPRINTPAGERANGE;typedef struct tagPDEX {
DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
HDC hDC;
DWORD Flags;
DWORD Flags2;
DWORD ExclusionFlags;
DWORD nPageRanges;
DWORD nMaxPageRanges;
LPPRINTPAGERANGE lpPageRanges;
DWORD nMinPage;
DWORD nMaxPage;
DWORD nCopies;
HINSTANCE hInstance;
LPCTSTR lpPrintTemplateName;
LPUNKNOWN lpCallback;
DWORD nPropertyPages;
HPROPSHEETPAGE *lphPropertyPages;
DWORD nStartPage;
DWORD dwResultAction;
} PRINTDLGEX, *LPPRINTDLGEX;In a button click handler the following code is done -
typedef HRESULT (\*Print)(LPPRINTDLGEX lppd); HMODULE hMod = LoadLibrary("C:\\\\WINNT\\\\system32\\\\comdlg32.dll"); Print prn = (Print)GetProcAddress(hMod, "PrintDlgExA"); PRINTDLGEX stprn; memset(&stprn, 0, sizeof PRINTDLGEX); stprn.lStructSize = sizeof PRINTDLGEX; stprn.hwndOwner = m\_hWnd; stprn.nCopies = 1; stprn.Flags = PD\_ALLPAGES|PD\_USEDEVMODECOPIES|PD\_HIDEPRINTTOFILE|PD\_NOPAGENUMS|PD\_NOSELECTION|0x00800000; stprn.Flags &= ~PD\_RETURNIC; stprn.nStartPage = -1; stprn.dwResultAction = 0; prn(&stprn);
Now the dialog is displayed but on closing the dialog it breaks. I suspect it to be the wrong parameter used as the callback routine in the
stprn.lpCallback
parameter of the structure. I tried giving many other parameters for the callback function, but in vain Has anybody done this or does anybody have an idea as to what I must do, please reply. Regards Santosh « Superman »