Article View: borland.public.cppbuilder.nativeapi
Article #12528Re: Windows Printers
From: John Scott
Date: Mon, 01 Dec 2003 20:26
Date: Mon, 01 Dec 2003 20:26
68 lines
3277 bytes
3277 bytes
Those corrections did not solve the problem.
WritePrinter() still returns 0 when strlen() was used. The value for
GetLastError() is 6!
I have examined each of the characters in PCLSideTwo in the debugger and
they are correct.
I tried the changes for DrawText and it made no difference. It looks like
DrawText is not transmitting the Esc character.
Do you have any idea what the error 6 means?
John
"JD" <nospam@nospam.com> wrote in message
news:3fcb9bc2$1@newsgroups.borland.com...
>
> "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:
<3fcba44a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!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> <3fcb9bc2$1@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 12:39:56 PST From: "John Scott" <jscott@kw.igs.net> Newsgroups: borland.public.cppbuilder.nativeapi 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> <3fcb9bc2$1@newsgroups.borland.com> Subject: Re: Windows Printers Date: Mon, 1 Dec 2003 15:26:54 -0500 Lines: 70 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 216.16.227.123 Message-ID: <3fcba44a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1070310474 216.16.227.123 (1 Dec 2003 12:27:54 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail