Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintDlg 1

Status
Not open for further replies.

SteveD73

Programmer
Jan 5, 2001
109
0
0
GB
Hello

Im using the following piece of code to display the print dialog:

pd.lStructSize = sizeof(PRINTDLG);
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.hwndOwner = hDlg;
pd.Flags = PD_RETURNDC;
pd.hInstance = hInst;

PrintDlg(&pd);

When I run my program in Debug mode all works fine. However, when I run my program in Release mode the print dialog fails to display. Any ideas why?

Thanks
 
I think you're not initialising enough of the structure. Adding the following lines works for me.

pd.nFromPage = 1;
pd.nToPage = 100;
pd.nMinPage = 1;
pd.nMaxPage = 100;
pd.nCopies = 1;

Experimentation suggests that you can get away with only some of these, but I got nasty values (e.g. Print Range : All 24382 pages) so I would set them all.

Jonathan Clarke
 
I think tooltired is right...
this one works for me eactly fine
PRINTDLG pd;
// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = m_hWnd;
pd.hDevMode = NULL;
pd.hDevNames = NULL;

pd.Flags = PD_HIDEPRINTTOFILE|PD_USEDEVMODECOPIESANDCOLLATE |PD_RETURNDC|/*PD_ALLPAGES|*/PD_NOSELECTION|PD_ENABLESETUPHOOK;
pd.hInstance = 0;
pd.lpPrintTemplateName = NULL;

pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top