Article View: borland.public.cppbuilder.nativeapi
Article #12527Re: Windows Printers
From: JD
Date: Mon, 01 Dec 2003 18:51
Date: Mon, 01 Dec 2003 18:51
52 lines
2631 bytes
2631 bytes
"John Scott" <jscott@kw.igs.net> wrote:
> [...] but the WritePrinter() function does not seem to work.
> When I check in the debugger the function returns 0 which
> indicates an error I believe.
You're correct that a return of zero indicates an error. In
that case, you need to call GetLastError to find out why it
failed:
if( !WritePrinter() )
{
// GetLastError
}
but I see a problem with your call to WritePrinter which may
correct the error:
sizeof( PCLSideTwo )
will always return the size of a character pointer because
PCLSideTwo is a character pointer. What you want is the string
length if PCLSideTwo instead:
strlen( PCLSideTwo )
> char *PCLSideTwo;
> PCLSideTwo="\x01B&a90P John Scott";
This type of assignment has been depreciated although I doubt
that it makes any difference. It should read:
char const *PCLSideTwo = "\x01B&a90P John Scott";
> DrawText(Printer()->Handle, PCLSideTwo, -1, &Rect, DT_NOCLIP + DT_NOPREFIX );
The '+' symbol should be replaced with '|':
DrawText(Printer()->Handle, PCLSideTwo, -1, &Rect, DT_NOCLIP | DT_NOPREFIX );
> If I try the commented code using DrawText() then the \x01B
> prints as a small square and the remaning text of PCLSideTwo
> is printed.
Changing the drawing flags ( | not + ) may fix your problem
but I'm not convinced that your assignment for PCLSideTwo is
correct. To be sure that the string is initialized with the
correct values, try something like this:
char CommandString[ some length ] = { 0x1B, ...., 0x00 };
~ JD
Technical Details
Message-ID:
<3fcb9bc2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.visi.com!petbe.visi.com!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com> <3fc77301@newsgroups.borland.com> <3fc7e524$1@newsgroups.borland.com> <3fca2474@newsgroups.borland.com> <3fcb2567$1@newsgroups.borland.com> <3fcb6984@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7b2449597708bec X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-01 11:52:34 PST From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Windows Printers Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.208.31.134 References: <3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com> <3fc77301@newsgroups.borland.com> <3fc7e524$1@newsgroups.borland.com> <3fca2474@newsgroups.borland.com> <3fcb2567$1@newsgroups.borland.com> <3fcb6984@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <3fcb9bc2$1@newsgroups.borland.com> Date: 1 Dec 2003 11:51:30 -0700 X-Trace: newsgroups.borland.com 1070308290 207.105.83.66 (1 Dec 2003 11:51:30 -0700) Lines: 53 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.visi.com!petbe.visi.com!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail