#include <windows.h> #include <commdlg.h> RECT rect ; HDC hdcPrn ; DOCINFO di = { sizeof (DOCINFO), TEXT ("EmfView: Printing") } ; HENHMETAFILE hemf; PRINTDLG printdlg = { sizeof (PRINTDLG) } ; TCHAR szAppName[] = TEXT ("EmfView") ; int main(void) { bool bSuccess; HWND hwnd ; // Affiche la boîte de dialogue Imprimer et récupère le contexte de périphérique imprimante printdlg.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION ; if (!PrintDlg (&printdlg)) return 0 ; if (NULL (hdcPrn printdlg.hDC)) { MessageBox (hwnd, TEXT ("Imprimante introuvable"), szAppName, MB_ICONEXCLAMATION | MB_OK) ; return 0 ; } // Récupère la zone imprimable de la page rect.left = 0 ; rect.right = GetDeviceCaps (hdcPrn, HORZRES) ; rect.top = 0 ; rect.bottom = GetDeviceCaps (hdcPrn, VERTRES) ; bSuccess = FALSE ; // Imprime SetCursor (LoadCursor (NULL, IDC_WAIT)) ; ShowCursor (TRUE) ; if ((StartDoc (hdcPrn, &di) > 0) && (StartPage (hdcPrn) > 0)) { PlayEnhMetaFile (hdcPrn, hemf, &rect) ; if (EndPage (hdcPrn) > 0) { bSuccess = TRUE ; EndDoc (hdcPrn) ; } } ShowCursor (FALSE) ; SetCursor (LoadCursor (NULL, IDC_ARROW)) ; DeleteDC (hdcPrn) ; if (!bSuccess) MessageBox (hwnd, TEXT ("Impossible d'imprimer le fichier"), szAppName, MB_ICONEXCLAMATION | MB_OK) ; return 0 ; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question