BOOL PrintDlg(PRINTDLG *InformationsImpression);
La description de l'imprimante est rangée dans InformationsImpression, en particulier son contexte graphique.
#include <windows.h>
#include <winbase.h>
HINSTANCE HandleInstance;
HWND HandleFenetre;
PRINTDLG InformationsImpression;
DOCINFO InformationsDocument;
InformationsImpression.lStructSize=sizeof(PRINTDLG);
InformationsImpression.hwndOwner=HandleFenetre;
InformationsImpression.hDevMode=0;
InformationsImpression.hDevNames=0;
InformationsImpression.hDC=0;
InformationsImpression.Flags=PD_RETURNDEFAULT|PD_RETURNDC;
InformationsImpression.nFromPage=0;
InformationsImpression.nToPage=0;
InformationsImpression.nMinPage=0;
InformationsImpression.nMaxPage=0;
InformationsImpression.nCopies=0;
InformationsImpression.hInstance=HandleInstance;
InformationsImpression.lCustData=0;
InformationsImpression.lpfnPrintHook=NULL;
InformationsImpression.lpfnSetupHook=NULL;
InformationsImpression.lpPrintTemplateName=NULL;
InformationsImpression.lpSetupTemplateName=NULL;
InformationsImpression.hPrintTemplate=NULL;
InformationsImpression.hSetupTemplate=NULL;
if (!PrintDlg(&InformationsImpression))
{
...
}
InformationsDocument.cbSize=sizeof(DOCINFO);
InformationsDocument.lpszDocName="Mon document";
InformationsDocument.lpszOutput=NULL;
InformationsDocument.lpszDatatype=NULL;
InformationsDocument.fwType=0;
if (StartDoc(InformationsImpression.hDC, &InformationsDocument)<=0)
{
...
}
...
if (StartPage(InformationsImpression.hDC)<=0)
{
...
}
...
if (EndPage((InformationsImpression.hDC)<=0)
{
...
}
...
if (EndDoc(InformationsImpression.hDC)<=0)
{
...
}
...
DeleteDC(InformationsImpression.hDC);
...