1. Printing - How to?

Hi all,
I am trying to create a print procedure for my program, following is my 
code but it all prints on one line. How do I send line feeds. Or am i 
doing something else wrong.
Also
How can i tell if the text is too long for a line?
How would i know when to start a new page?
 
procedure HistoryPrintButton_onClick ()
sequence result, itemselected, text, HistoryKey, HistoryData, cur
atom i, qtyrecords
cur = { 13, 10 }
i=1
result = getPrinter()
if length(result) then
    if not startDoc( sprintf( "KeyTrack History Report, Cop %s", {i})) 
then
--        exit
    end if
 
    if not startPage() then
--        exit
    end if
 
    wPuts( Printer, "KeyTrack V1.0 History Report for " & 
getText(HistoryItem) & cur)
 
    qtyrecords = getLVCount( HistoryList )
    for x = 1 to qtyrecords do
        itemselected= {x}
        if length( itemselected ) then  
            text = value(getLVItemText( HistoryList, itemselected[1],3)) 
 
            curRecord = text[2]  
            setText(HistoryDate, getLVItemText( HistoryList, 
itemselected[1],1)) 
            setText(HistoryTransaction, getLVItemText( HistoryList, 
itemselected[1],2)) 
            HistoryKey = db_record_key(curRecord) 
            HistoryData = db_record_data(curRecord) 
            setText(HistoryTime, sprintf("%d",HistoryKey[4]) & ":" & 
sprintf("%d",HistoryKey[5]) & ":" & sprintf("%d",HistoryKey[6])) 
            if length(HistoryData) > 1 then 
                setText(HistoryNotes, HistoryData[2]) 
            else 
                setText(HistoryNotes, "No notes on file") 
            end if 
        end if
        wPuts( Printer, "Date " & getText(HistoryDate) & "          Time 
" & getText(HistoryTime))
        wPuts( Printer, cur)  
        wPuts( Printer, "Transaction " & getText(HistoryTransaction) & 
cur)
        wPuts( Printer, "Notes " & getText(HistoryNotes) & cur)
        wPuts( Printer, 
    end for
 
    if not endPage() then
--        exit
    end if
 
    if not endDoc() then
--        exit
    end if
 
    releasePrinter()
end if
end procedure

Thanks
Tony Steward
 

Come visit me at www.locksdownunder.com

new topic     » topic index » view message » categorize

2. Re: Printing - How to?

On Tue, 06 Feb 2001, Tony Steward wrote:
> Hi all,
> I am trying to create a print procedure for my program, following is my 
> code but it all prints on one line. How do I send line feeds. Or am i 
> doing something else wrong.
> Also
> How can i tell if the text is too long for a line?
> How would i know when to start a new page?

You have to determine the page size and the font size, and keep track 
of how much page is left after each line is printed. Here's a snippet of 
code - not neat, but it has been working for a couple of years without 
fail :^)

Regards,
Irv
result = getFontSize(Printer)
fontY = result[2]
result = getExtent(Printer)
pageY = result[2]
y  = 0
header[1] = sprintf(tab(90)&"Page %d",pg)
pg += 1
doc = header & doc
while True do
 if length(doc) = 0 then exit
 end if
if y + fontY > pageY then exit
 end if
setPosition(Printer, 0, y) -- note!
wPuts(Printer,doc[1])
doc = doc[2..length(doc)]
y += fontY
end while
if not endPage() then printErr = True
end if
return doc
end function

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

3. Re: Printing - How to?

------=_NextPart_000_01C09033.B1F30700

..on that note...
Here's a little demo that uses the DrawText() *function*, which would be a
lot nicer if a variation of this were 'wrapped' into win32lib.

The demo will only work *if* putFontIntoHDC() is declared as global in
win32lib.

DrawText() has some obvious features which would make it a lot easier to
print using win32lib.

Wolf

------=_NextPart_000_01C09033.B1F30700
Content-Description: drawtest.exw (EXW File)

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

4. Re: Printing - How to?

------=_NextPart_000_01C0904A.937D0E80

Just to see how easy it might be to wrap DrawText(), I tried a printdraw.ew,
with a new example, drawtest2.exw.
Again, because it's inside win32lib, putFontIntoHDC() must be declared as
global for the demo.
.. bugs and questions a'plenty ...
ink_waster_Wolf

------=_NextPart_000_01C0904A.937D0E80
Content-Description: drawtest2.ZIP (WinZip File)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu