At the time of writing this extra lesson, Win32lib.ew did not yet include any interface to the Windows print spooler. I created the include ( printw.ew ) using routines written by Jacques Dechenes in his api_wrap package as a temporary file that would allow at least some basic printing to be done through Windows, using the 'default' system printer.
This program simply illustrates how to print using the print spooler using this .ew. In order to use the spooler, one has to first create the necessary links to the Windows .dlls concerned with printing. Printw.ew does this.
These are the original notes I included with my first distribution of this program.
..end of extra_02.
One then creates a 'handle' to the default printer using DefaultPrinterName(), and GetPrinterDC().
Then one uses:
GetTextMetrics() to determine the page extents. ( size of default page )
and the 'default' printer's font size.
StartDoc() to start a print document.
StartPage() to start a page in the document.
pTextOut() to 'print' to the printer. ( see caution below ! )
EndPage() to complete that page.
...
EndDoc() to finish the document, and ...
DeleteDC() to 'release' the 'handle' for the print job.
-- pr123.exw
include win32lib.ew
include printw.ew
without warning
-- create the window and menu.
constant MenuWin =
create(Window,"Print Demo",0,Default,Default,340,130,0)
constant
PopupFile = create(Menu,"&File",MenuWin,0,0,0,0,0),
MenuPrint = create(MenuItem,"&Print",PopupFile,0,0,0,0,0),
MenuSep1 = create(MenuItem,"-",PopupFile,0,0,0,0,0),
MenuExit = create(MenuItem,"E&xit",PopupFile,0,0,0,0,0),
PopupHelp = create(Menu,"&Help",MenuWin,0,0,0,0,0),
MenuAbout = create(MenuItem,"&About",PopupHelp,0,0,0,0,0),
Dummy = create(Menu," -prints 3 pages thru FILE,PRINT-",MenuWin,0,0,0,0,0)
setFont( MenuWin,"Courier New",10,1)
procedure onMenu_MenuAbout()
integer result
result = message_box("Win32Lib Print Demo, prints itself !",
"HELLO !",#2000)
end procedure
onClick[MenuAbout] = routine_id("onMenu_MenuAbout")
integer Handle
object line
procedure print_stuff(sequence a) --a is filename
atom myphdc, i, j, charheight, width, hor, ver
sequence mypr, textinfo, string1
mypr=DefaultPrinterName()
myphdc=GetPrinterDC(mypr)
textinfo=GetTextMetrics(myphdc)
charheight=textinfo[1]+1 --character height+1,
..This program ( and printw.ew ) requires win32lib.ew, and it's contents
were shamelessly "stolen" from the win32lib and api_wrap packages,
by David Cuny and Jacques Deschenes.
The included printw.ew is mostly a "cut" and "paste" of the original
api_wrap code, modified just enough to work with the win32lib package.
While this program pretends to offer a print demo using win32lib.ew, I
cannot guarantee that it works anywhere else but on my own computer.
It will no-doubt crash if your printer can't do "some" graphics, since
I have NOT included the standard test for printer capability in my
demo.
* caution *
The pTextOut procedure is a "bastard" invention of mine which does not
exist in the standard Win32 API, and will thus, probably disappear
when Mr. Cuny adds printing functions to his win32lib.ew, but I believe
it's the only one, so it shouldn't be too hard to replace in your source
code later.
You would also have to remove the reference to my printw.ew 'include'.
It should not effect any .exe's you create now, however.
Meanwhile, you CAN play around with Windoze printing thru the "default"
printer. ;-)
Wolf
wolfritz@king.igs.net