1. windoze printing

...any windoze folks out there who can TEST this code-chunk for me ?
Uses the api_wrap stuff...
My "dinky" printer does not allow any font settings in printer properties, so
I'm not sure if I got the TextMetrics "thingie" right or not. Any simple
Notepad text should serve as input.
** caution ** comment out the global function DeleteDC() at the end of
print.ew, as it conflicts with the procedure DeleteDC() in gdi32.ew...
...any feedback much appreciated...Wolf
------------------------------------------------
include gdi32.ew
include print.ew
include msgbox.e

procedure print_stuff(sequence a) -- a is filename
atom myprinterhdc, i, charheight
sequence myprintername, textinfo
i=message_box("make sure printer is on !"," ",#2000)
myprintername=DefaultPrinterName() -- uses the default printer
myprinterhdc=GetPrinterDC(myprintername)
textinfo=GetTextMetrics(myprinterhdc)
charheight=textinfo[1]
i=StartDoc(myprinterhdc, a )
i=StartPage(myprinterhdc)
TextOut(myprinterhdc,360,30,"A Printing Example")
 Handle=open( a ,"r")
 j=charheight
   while 1 do
     line=gets(Handle)
     if atom(line) then exit end if
     line=line[1..(length(line)-1)] -- remove the line feed.
     TextOut(myprinterhdc,0,j,line )
     j=j+charheight
   end while
 close(Handle)
i=EndPage(myprinterhdc) -- eject page
i=EndDoc(myprinterhdc) -- and close
DeleteDC(myprinterhdc)
end procedure
-- hey ! no error checking blink
-------------------------------------------------------
..with a little web-page at http://www.king.igs.net/~wolfritz

new topic     » topic index » view message » categorize

2. Re: windoze printing

..apologies to anyone, my previous windows printing post only worked for
people ( like me ) using ew32.dll. I have managed to create a Windows print
demo using win32lib.ew by "stealing" most of the relevant code from the
api_wrap package. Since it will become obsolete whenever Mr. Cuny gets to
work on printing.... I hesitate to post it here. Anyone really interested in
this...I'll mail it to you !
   wolfritz at king.igs.net
-------------------------------------------------------
..with a little web-page at http://www.king.igs.net/~wolfritz

new topic     » goto parent     » topic index » view message » categorize

3. Re: windoze printing

Wolfgang wrote:
>..apologies to anyone, my previous windows printing post only worked for=

>people ( like me ) using ew32.dll. I have managed to create a Windows
print
>demo using win32lib.ew by "stealing" most of the relevant code from the
>api_wrap package. Since it will become obsolete whenever Mr. Cuny gets t=
o
>work on printing.... I hesitate to post it here. Anyone really intereste=
d
in
>this...I'll mail it to you !

Beforehand my apologies to David Cuny: what I'm about to say is not in an=
y
way ment as critizism. But it is certainly not forbidden to 'help' Mr.
Cuny. If we think we found something that is not yet in Win32Lib, cannot =
we
experiment with it?
And besides that, code provided by Jacques Dechenes is not that bad, IMO.=

And *if* something goes wrong, Mr. Cuny will always be there to give us a=

stern answer and an advice to recode things again.
But I can understand that David wants to leave his own code his own code.=

So if we add some functionality because we need it or just by
experimenting, we should provide our own include files, that maybe later
can be implemented in Win32Lib, when it's Davids time to do that.
But in the mean time I think I have the right to experiment in Windhoos
programming, and I think everyone willing to should claim that right.

P.S. Does any1 of know the 'Envelop Engine' programming language? I have
been playing around with it for some time and sometimes it look promising=
,
but there are also a few drawbacks to it....

Thanks,

Ad

new topic     » goto parent     » topic index » view message » categorize

4. Re: windoze printing

Ad wrote:

> But it is certainly not forbidden to 'help' Mr. Cuny.
> If we think we found something that is not yet in Win32Lib,
> cannot we experiment with it?

By all means, please do so!


> And besides that, code provided by Jacques Dechenes is not
> that bad, IMO.

I've given serious thought to gutting my own code in Win32Lib and
replacing it with Jacques'. He is certainly much better at coding
this Win32 stuff than I am. But right now, it's just too much effort.


> So if we add some functionality because we need it or just by
> experimenting, we should provide our own include files, that
> maybe later can be implemented in Win32Lib, when it's Davids time
> to do that.

And if I can just include your code without changing Win32Lib, so much
the better. I'll be glad to give credit where credit is due.

Adding routines that wrap simple API calls is fairly easy. Just convert the
window id into a handle with getHandle.

Graphics are only a bit more complex. Look at drawRectangle() for a
typical graphic API wrapper. Here's the deal:

1. Use getDC() and releaseDC() to grab the DC of what you want to read
   and write to. Typically, this is done within the context of an onPaint
   call, and the DC has already been grabbed. These routines take care
   of the details.

2. If you need to draw with a pen, be sure to call createPen() before you
   make the API call. This creates a pen using the attributes assigned in
   setPenColor() and setPenStyle().

3. If you need to call SelectObject for a GDI resource , use replaceObject()

   instead. This is my "garbage collection" routine for GDI resources, to
   prevent memory leaks.

   Calling replaceObject automatically releases the prior resource (if it
   is not a stock object), and releases the selected object at the end of
   the onPaint call, or at the end of the program.


> But in the mean time I think I have the right to experiment in
> Windhoos programming, and I think everyone willing to should claim
> that right.

Yes!


> Does any1 of know the 'Envelop Engine' programming language?

I downloaded it once, but never actually tried it. The project has been
officially been abandoned, which is a pity. A free alternative to VB, but
the size was a bit much.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

5. Re: windoze printing

David Cuny:

Thanks for your comments and remarks. I'll keep them in a safe place to
look at it later. At the moment, it is (unfortunately) still double dutch=

to me.
I think I need to write a Win32 tutorial for myself, starting with an ind=
ex
of words and terms that are more or less unclear to me. Maybe others can
profit of this too. At least one person on the listserv asked for somethi=
ng
like this.

Now if I will put up this project, especially the beginning will be writt=
en
for my own sake. I want to start off with the basics. When we know what w=
e
want to ask, we can always call in the real Windhoos gurus. (I like to
leave in the joke 'Windhoos' (Ralf's), for translated in english it means=

something like 'bag of wind')
Is there anyone here interested in such a project?

Hope to hear from you!

Ad

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu