HENHMETAFILE QueryOpenEMFFile(TCHAR szFileName[]) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, _T("emf|spl"), _T("Enhanced Metafiles|Win NT/2000 EMF Spool Files")) ) { if ( szFileName ) _tcscpy(szFileName, fd.m_TitleName); return GetEnhMetaFile(fd.m_TitleName); } else return NULL; }
void Demo_WritePort(void) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, "prn", "Raw printer data") ) { HANDLE hPort = CreateFile("lpt1:", GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if ( hPort!=INVALID_HANDLE_VALUE ) { SendFile(hPort, fd.m_TitleName, false); CloseHandle(hPort); } } }
void Demo_WritePrinter(void) { PRINTDLG pd; memset(&pd, 0, sizeof(PRINTDLG)); pd.lStructSize = sizeof(PRINTDLG); if ( PrintDlg(&pd)==IDOK ) { HANDLE hPrinter; DEVMODE * pDevMode = (DEVMODE *) GlobalLock(pd.hDevMode); PRINTER_DEFAULTS prn; prn.pDatatype = "NT EMF 1.008"; prn.pDevMode = pDevMode; prn.DesiredAccess = PRINTER_ACCESS_USE; if ( OpenPrinter((char *) pDevMode->dmDeviceName, & hPrinter, & prn) ) { KFileDialog fd; if ( fd.GetOpenFileName(NULL, "spl", "Windows 2000 EMF Spool file") ) { DOC_INFO_1 docinfo; docinfo.pDocName = "Testing WritePrinter"; docinfo.pOutputFile = NULL; docinfo.pDatatype = "NT EMF 1.008"; StartDocPrinter(hPrinter, 1, (BYTE *) & docinfo); StartPagePrinter(hPrinter); SendFile(hPrinter, fd.m_TitleName, true); EndPagePrinter(hPrinter); EndDocPrinter(hPrinter); } ClosePrinter(hPrinter); } if ( pd.hDevMode ) GlobalFree(pd.hDevMode); if ( pd.hDevNames ) GlobalFree(pd.hDevNames); } }