It seems to me like kind of incompatibility or my guess is wrong?
Please help me I am a newbier in develoing native applications since I
am .net programmer:)
I am looking for printing solution that will wotk with USB printer. I
have tryed a couple of libraries - they work fine with network
printers but not with USB:(. I have included USB printer driver to my
OS image and I have all th settings for printng in registry (according
to MSDN)
Maybe I am missing something ?
Thank you guys for your help
The PAGESETUPDLG is in commdlg.h. DOCINFO is in wingdi.h, but that should
be included when you include windows.h. You might need winx.h to get
MulDiv(), but I don't see the need for winddi.h. My print sample code all
just includes the pre-compiled header file set up by the new project wizard
in eVC or Visual Studio, commctrl.h, commdlg.h, and winx.h. No compile
problems.
Paul T.
"Igor Golikov" <sali...@gmail.com> wrote in message
news:bd5a1445-cdec-447f...@o5g2000prh.googlegroups.com...
Hi Paul
Well I have to include prnport.h to have PrinterOpen and PrinterSend,
haven't I?
And then I need to use DrvStartDocument - I understand it is in
winddi.h.
If you have some full printing example I willk be glad to learn from
it.
Thanks
It depends on your application architecture. If you use PrintDlg() or
PageSetupDlg() to show the user the printer settings, that returns the HDC
for the printer. You simply draw to that HDC, just as you would to the
screen, and the result is something on the printer. As mentioned, you have
to call StartDoc(), StartPage(), EndPage(), and EndDoc() to get the printer
driver to properly handle pagination and the whole job, but that's really
it. Here's some code from an application that uses the obsolete PrintDlg()
function, but should work:
// Show the print dialog.
PRINTDLG pd;
memset( &pd, 0, sizeof( pd ) );
pd.cbStruct = sizeof( pd );
pd.hwndOwner = hWnd;
pd.dwFlags = 0;
if ( PrintDlg( &pd ) )
{
// We have a DC for printing. Draw something to
// it.
DOCINFO di;
di.cbSize = sizeof( di );
di.fwType = 0;
di.lpszDatatype = 0;
di.lpszDocName = _T( "Test document" );
di.lpszOutput = NULL;
int jobid = StartDoc( pd.hdc, &di );
if ( jobid > 0 )
{
// Select a suitable font, pen, brush, or
// whatever.
LOGFONT lf;
lf.lfHeight = -(int)MulDiv( 20,
GetDeviceCaps( pd.hdc, LOGPIXELSY ), 72 );
lf.lfWidth = 0;
lf.lfEscapement = 10;
lf.lfOrientation = 10;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = FALSE;
lf.lfUnderline = FALSE;
lf.lfStrikeOut = FALSE;
lf.lfCharSet = ANSI_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = CLEARTYPE_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH || FF_ROMAN;
_tcscpy( lf.lfFaceName, _T( "" ) ); // Allow the font mapper to pick.
HFONT hf = CreateFontIndirect( &lf );
HFONT oldhf = (HFONT)SelectObject( pd.hdc, hf );
// Start the next page.
StartPage( pd.hdc );
RECT r;
r.top = 0;
r.bottom = 500;
r.left = 0;
r.right = 2000;
DrawText( pd.hdc, _T( "This is a test string" ), -1,
&r, DT_LEFT );
EndPage( pd.hdc );
SelectObject( pd.hdc, oldhf );
DeleteObject( hf );
// End the document and release the printer
// to finish it.
EndDoc( pd.hdc );
}
// Clean up the DC created by the print dialog for
// us.
DeleteDC( pd.hdc );
}
You would certainly never ever call DrvStartDocument(). That's a function
directly in the printer driver. The OS is responsible for doing that.
Paul T.