Re: Printing - Page number paradox
Posted: Wed Mar 29, 2017 8:48 pm
Ok, Claudio. Thank you.
I was looking into new release. I am compiling all demos at SAMPLES.
I was looking into new release. I am compiling all demos at SAMPLES.
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://hmgforum.com/
Hi Pablo,Pablo César wrote: ↑Wed Mar 29, 2017 5:44 pm Hi Karl, have you be welcome to our community.
Sorry I did not understand you regarding button, pages.
I translated your short code but I did not understood.
Hi Rathi,Rathinagiri wrote: ↑Fri Mar 31, 2017 4:26 pm I think you don't need to get the button pushed twice. You can call the same function again which is called with the button action procedure. Right?
Thank you very much Rathi for this tip. This means a lot of work for me because I never before changed source code or used parts of it in my own code. If I am successful, I will inform you immediately. Now I try.....Rathinagiri wrote: ↑Sat Apr 01, 2017 8:11 am Yes. You have to call your own "Function RichEditBox_RTFPrint" as in h_richeditbox.prg in sources directory starting line number 385.
Code: Select all
*----------------------------------------------------------------------------------------------------------*
Function RichEditBox_MyRTFPrint ( hWndControl, aSelRange, nLeft, nTop, nRight, nBottom, PrintPageCodeBlock )
*----------------------------------------------------------------------------------------------------------*
LOCAL nPageWidth, nPageHeight
LOCAL nNextChar := 0
LOCAL nTextLength := RichEditBox_GetTextLength ( hWndControl )
DEFAULT aSelRange TO { 0, -1 } // select all text
DEFAULT nLeft TO 20 // Left page margin in millimeters
DEFAULT nTop TO 20 // Top page margin in millimeters
DEFAULT nRight TO 20 // Right page margin in millimeters
DEFAULT nBottom TO 20 // Bottom page margin in millimeters
DEFAULT PrintPageCodeBlock TO {|| NIL}
nPageWidth := OpenPrinterGetPageWidth() // in millimeters
nPageHeight := OpenPrinterGetPageHeight() // in millimeters
nRight := nPageWidth - nRight
nBottom := nPageHeight - nBottom
// Convert millimeters in twips ( 1 inch = 25.4 mm = 1440 twips )
nLeft := nLeft * 1440 / 25.4
nTop := nTop * 1440 / 25.4
nRight := nRight * 1440 / 25.4
nBottom := nBottom * 1440 / 25.4
IF aSelRange [2] == -1 .OR. aSelRange [2] > nTextLength
aSelRange [2] := nTextLength
ENDIF
START PRINTDOC
DO WHILE nNextChar < nTextLength
START PRINTPAGE
EVAL ( PrintPageCodeBlock )
nNextChar := RichEditBox_FormatRange ( hWndControl, OpenPrinterGetPageDC(), nLeft, nTop, nRight, nBottom, aSelRange )
aSelRange [1] := nNextChar
DO EVENTS
END PRINTPAGE
ENDDO
END PRINTDOC
Return Nil
Rathi this was a very great help for me. Thanks a lot. I would have never figured out to go with the call RichEditBox_myRTFPrint(Form_81.Edit_1.handle, ...........). But first I had to delete the DEFAULTs in the call. Now it works. The main goal was to push the close button by the program. I´m going on now and will report to you if I will be sucessful.Rathinagiri wrote: ↑Sat Apr 01, 2017 3:34 pm First you try to run without modifying the source code but by calling your own function. Then try to modify your own function. You can be successful.
Code: Select all
SELECT PRINTER default TO lSuccess // just a dummy printer if you want to specify the page size, you can fix that also here.
Code: Select all
pages := 0
START PRINTDOC
DO WHILE nNextChar < nTextLength
START PRINTPAGE
pages ++
EVAL ( PrintPageCodeBlock )
nNextChar := RichEditBox_FormatRange ( hWndControl, OpenPrinterGetPageDC(), nLeft, nTop, nRight, nBottom, aSelRange )
aSelRange [1] := nNextChar
DO EVENTS
END PRINTPAGE
ENDDO
ABORT PRINTDOC