Print On WinCE4.2 - Windows CE
This is a discussion on Print On WinCE4.2 - Windows CE ; I use platform builder4.2,and I add all the priter drivers needed to my
project.Now I can use WordPad to print correctly.The printer is HP
LaserJet 1022n.But the App I programed myself dosn't work
correctly.When I press my Print Button,The printer ...
-
Print On WinCE4.2
I use platform builder4.2,and I add all the priter drivers needed to my
project.Now I can use WordPad to print correctly.The printer is HP
LaserJet 1022n.But the App I programed myself dosn't work
correctly.When I press my Print Button,The printer put's a sheet of
paper, but doesn't print anything.
The Code is as follows:
void CTestPrinterDlg::OnButtonPrint()
{
// TODO: Add your control notification handler code here
CDC dc;
RECT rect;
HDC hdc;
int i;
TCHAR DebugStr[20];
DEVMODE devmod;
DOCINFO di;
// devmod.dmFields=DM_ORIENTATION | DM_PRINTQUALITY;
dc.CreateDC(NULL,_T("HP LaserJet 1022n"),NULL,NULL); //Print on Screen
hdc=CreateDC(_T("PCL.DLL"),_T("HP LaserJet
1022n"),_T("LPT1:"),&devmod);//Print on Printer
// hdc=CreateDC(NULL,_T("HP LaserJet 1022n"),_T("LPT1:"),&devmod);
if(!hdc)
MessageBox(_T("Create hdc Error"),_T("INFO"),MB_OK);
di.cbSize = sizeof( DOCINFO);
di.lpszDocName = _T("My test");
// StartDoc(hdc,&di);
if(!StartDoc(hdc,&di)){
wsprintf(DebugStr,_T("StartDoc i=%d"),i);
MessageBox(DebugStr,_T("INFO"),MB_OK);
}
dc.Ellipse(0,0,100,100);
DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
rect.left = 0;
rect.top = 0;
rect.bottom = 30;
rect.right = 550;
dc.DrawText(_T("Test Printer"),&rect,NULL);
DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
rect.left = 15;
rect.top = 20;
rect.bottom = 30;
rect.right = 550;
dc.DrawText(_T("Test Printer"),&rect,NULL);
DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
rect.left = 15;
rect.top = 60;
rect.bottom = 80;
rect.right = 550;
dc.DrawText(_T("Test Printer"),&rect,NULL);
DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
EndDoc(hdc);
DeleteDC(hdc);
}
Any suggestion will be welcome.
Thanks in advance.
Brian
-
Re: Print On WinCE4.2
If you are going to ask the same question in multiple newsgroups, you
really should post to all of them at the same time, so everyone can
see and/or participate in the whole discussion. In this case, this is
really not an appropriate newsgroup anyway. You received at least one
reply in microsoft.public.windowsce.app.development
On 23 Sep 2006 21:50:25 -0700, "sunrain" wrote:
>I use platform builder4.2,and I add all the priter drivers needed to my
>project.Now I can use WordPad to print correctly.The printer is HP
>LaserJet 1022n.But the App I programed myself dosn't work
>correctly.When I press my Print Button,The printer put's a sheet of
>paper, but doesn't print anything.
>
>The Code is as follows:
>void CTestPrinterDlg::OnButtonPrint()
>{
> // TODO: Add your control notification handler code here
> CDC dc;
> RECT rect;
> HDC hdc;
> int i;
> TCHAR DebugStr[20];
> DEVMODE devmod;
> DOCINFO di;
>
>// devmod.dmFields=DM_ORIENTATION | DM_PRINTQUALITY;
> dc.CreateDC(NULL,_T("HP LaserJet 1022n"),NULL,NULL); //Print on Screen
>
> hdc=CreateDC(_T("PCL.DLL"),_T("HP LaserJet
>1022n"),_T("LPT1:"),&devmod);//Print on Printer
>// hdc=CreateDC(NULL,_T("HP LaserJet 1022n"),_T("LPT1:"),&devmod);
>
>
> if(!hdc)
> MessageBox(_T("Create hdc Error"),_T("INFO"),MB_OK);
>
>
> di.cbSize = sizeof( DOCINFO);
> di.lpszDocName = _T("My test");
>
>// StartDoc(hdc,&di);
>
> if(!StartDoc(hdc,&di)){
> wsprintf(DebugStr,_T("StartDoc i=%d"),i);
> MessageBox(DebugStr,_T("INFO"),MB_OK);
> }
>
> dc.Ellipse(0,0,100,100);
> DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
>
>
> rect.left = 0;
> rect.top = 0;
> rect.bottom = 30;
> rect.right = 550;
> dc.DrawText(_T("Test Printer"),&rect,NULL);
> DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
>
>
> rect.left = 15;
> rect.top = 20;
> rect.bottom = 30;
> rect.right = 550;
> dc.DrawText(_T("Test Printer"),&rect,NULL);
> DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
>
>
> rect.left = 15;
> rect.top = 60;
> rect.bottom = 80;
> rect.right = 550;
> dc.DrawText(_T("Test Printer"),&rect,NULL);
> DrawText(hdc,_T("Test my Printer"),32,&rect,NULL);
>
> EndDoc(hdc);
> DeleteDC(hdc);
>
>
>}
>
>Any suggestion will be welcome.
>Thanks in advance.
>
>Brian
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com