FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A sample to print with REPrintBox5 a memo on two pages ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 05:42 PM
Hello,

I'm looking for a simple way to print with richedi5 a memofield on two pages
I Added a print-button to the sample-collector for printing samples.
Just a textsplitting is needed ( max 2 pages nothing special )
I couln't find any sample.

One page printing of imported topics

Code (fw): Select all Collapse
STATIC FUNCTION PRINTTOPIC( lPreview, oTCode, cTopic, cTAuthor, cTLink )
LOCAL oPrn

LOCAL aRTF := { 0, 100 } 聽// { nFrom, nTop }

DEFINE FONT oBold NAME "Arial" SIZE 0,-56 BOLD
DEFINE FONT oMono NAME "Arial" SIZE 0,-12

DEFAULT lPreview := .f.

IF lPreview
聽 聽 PRINT oPrn NAME "FWH SAMPLE FILE" PREVIEW
ELSE
聽 聽 PRINT oPrn NAME "FWH SAMPLE FILE"
ENDIF

IF EMPTY( oPrn:hDC )
聽 聽 聽 聽 聽MsgStop( "Printer not ready!" )
聽 聽 聽 聽 聽RETURN NIL
ENDIF

PAGE
聽 聽 聽 聽 聽CURSORWAIT()

聽 聽 聽 聽 oPrn:InchSay( 0.40, 0.95, cTopic, oBold )
聽 聽 聽 聽 oPrn:InchSay( 0.50, 0.95, cTAuthor, oBold )
聽 聽 聽 聽 oPrn:InchSay( 0.60, 0.95, cTLink, oBold )

聽 聽 // 聽 nFrom := REPrintBox5( ::hWnd, hDC, ::IsSelection(), ;
聽 聽 // 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽nTop, nLeft, nRight, nBottom, nFrom )
聽 聽 聽 聽 聽aRTF := REPrintBox5( oTCode:hWnd, If( lPreview, oPrn:hDCOut, oPrn:hDC ), ;
聽 聽 聽 聽 聽 聽 聽 聽 oTCode:IsSelection(), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aRTF[ 2 ] + 500, 聽500, 3500, aRTF[ 2 ] + 5500, aRTF[ 1 ] )
聽 
聽 聽 聽 聽 聽CursorArrow()
ENDPAGE

ENDPRINT

oBold:End()
oMono:End()

RETURN NIL





regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 07:17 PM
Uwe
I do not know if I have understood your question correctly, but you can insert a page break in your text when you need it

Code (fw): Select all Collapse
oRTF: PageBreak ()


Also you have methods and data for you editor
Code (fw): Select all Collapse
聽 聽DATA 聽 lShowPageBreak

聽 聽METHOD HidePageBreak()
聽 聽METHOD ShowPageBreak()

聽 METHOD PageSetup( nTop, nLeft, nRight, nBottom )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:20 PM
Christobal,

I scanned the complete forum and found 42 topics about richedit

but NO infos about a textbreak during printing to a new page
Do You mean to count the lines and include a pagebreak on a defined position BEFORE printing ?



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:25 PM

This is a old method of richedit ( and also for richedit5 )

viewtopic.php?f=16t=6594p=29464hilit=PageBreak#p29464

That's why I have not mentioned it

&&&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:30 PM
ukoenig wrote:Christobal,

Do You mean to count the lines and include a pagebreak on a defined position BEFORE printing ?

regards
Uwe :-)

Uwe
Explain the reason for your question in the firts topic
I think I have not understood your needs well
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:41 PM
Cristobal,

I counted 60 lines of possible code printing the first page.
That means for topics > 60 lines in size I need a second page for printing.
It is just a textsplitting I need.
I noticed a maximum of possible 2 pages a topic might need for printing.
No problem on other printings I've done before but richedit is different.

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:46 PM
ukoenig wrote:Cristobal,

I counted 60 lines of possible code printing the first page.
That means for topics > 60 lines in size I need a second page for printing.
It is just a textsplitting I need.
I noticed a maximum of possible 2 pages a topic might need for printing.
No problem on other printings I've done before but richedit is different.

regards
Uwe :-)

Now I think I understand what you mean
Are you looking for an automatic way to format the printout in the required pages of the RichEdit5 control text?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:51 PM
Cristobal,

Yes that is what I mean. 90 % of the topic-code is small in size and only 1 page is needed
but I would like to cover bigger text as well.

Now I think I understand what you mean
Are you looking for an automatic way to format the printout in the required pages of the RichEdit5 control text?


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Thu Feb 22, 2018 08:57 PM
Ok
You have

Code (fw): Select all Collapse
oRTF:LastLineVisible()
//and
 oRTF:GetLineCount()

//after
 oRTF:GotoLine( nLine )   // calculate line from LastLineVisible and GetLineCount and insert PageBreak


Please, If I can help you with anything, tell me
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sat Feb 24, 2018 05:45 PM
Cristobal,

printing on multiple pages works but I didn't use pagebreak.

Next I want to show colored keywords.
I think it is not tested showing / refresh a new text on xbrowse row-change.
Adding HIGHLIGHT is giving a terrible effect :
the complete dialog is < fllckering / refreshed > on row-change and the display slows down.
I think using it on a standalonetext it doesn't matter but not for a fast text-changing with xBrowse.

@ 40, 625 RICHEDIT5 oTCode VAR cTCode OF oDlg SIZE 600, 410 ; // w h
FONT oFont PIXEL HSCROLL HIGHLIGHT :-)

with my next release I can include the normal and a version with activated highlight

maybe there is another solution possible

NO bad effects using :

Colorize( nStart, nEnd, nColor )

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sat Feb 24, 2018 05:52 PM
Did you look at this ? Seems to work for Xbrowse

Compile in samples

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "RichEdit.ch"

function Main()

聽 local cTitle:="Test"
聽 local cResult, oMemo
聽 Public cShowstr:=""
聽 Public oDlg

聽 REQUEST DBFCDX

聽 聽USE clients via "DBFCDX" NEW

聽 聽DEFINE FONT oFont NAME "Courier New" SIZE 8,15
聽 聽DEFINE FONT oBold NAME "Courier New" BOLD SIZE 8,15

聽 聽DEFINE DIALOG oDlg FROM 5,10 TO 50, 200 font oFont TITLE "Test Color"

聽 聽@ 10, 10 XBROWSE oBrw OF oDlg ;
聽 聽 聽 SIZE 400, 200 PIXEL ;
聽 聽 聽 COLUMNS 'Name', 'Adress', 'Notes' ;
聽 聽 聽 ALIAS 'CLIENTS' NOBORDER

聽 聽WITH OBJECT oBrw

聽 聽 聽 :nColDividerStyle := LINESTYLE_LIGHTGRAY
聽 聽 聽 :nRowDividerStyle := LINESTYLE_LIGHTGRAY
聽 聽 聽 :bClrRowFocus 聽 聽 := { || { CLR_BLACK, RGB(185,220,255) } }
聽 聽 聽 :nMarqueeStyle 聽 聽:= MARQSTYLE_HIGHLROWMS

聽 聽 聽 :bChange := { || oSay:refresh(),showmemo() }

聽 聽 聽 :CreateFromCode()
聽 聽END

聽 聽@ 10,460 SAY oSay PROMPT clients->notes SIZE 200,200 PIXEL OF oDlg COLOR CLR_BLACK update 聽//TRANSPARENT

聽 聽ACTIVATE DIALOG oDlg CENTERED

聽 聽close all
Return nil

function showmemo()
聽 聽Local cStr:=""
聽 聽local cChange:= "FiveWin" 聽 // 聽Word that we will look for
聽 聽local cInto:= "\cf2 FiveWin \cf1" 聽// Put Word in Color


聽 聽cText = alltrim(clients->notes)

聽 聽cStr 聽+= "{\rtf1\ansi\deff0"
聽 聽cStr 聽+= "{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}"
聽 聽cstr 聽= cStr + cText
聽 聽cStr 聽+= "}"

聽 聽cShowStr = StrTran( cStr, cChange, cInto ) 聽// --> "Harbour Power"

聽 聽hDLL = LoadLibrary( 'riched20.dll' )
聽 聽@ 250,900 RICHEDIT oMemo VAR cShowstr of oDlg PIXEL SIZE 300,400

return NIL
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sat Feb 24, 2018 06:06 PM
Marc,

thank You I will ckeck it
It is number 4 position of the browser.
All what we need is coloring the filtertext inside the memo

The result importing from the FWH-sample direcory
1085 files and 12 files filtering the keyword richedit
done in just 5 minutes time :-)

I tested the function but doesn't work

in xbrowse included

:bChange := { || SHOWMEMO(oTCode, ALLTRIM(cTCode), ALLTRIM(cTFilter)), ;
...
...

@ 40, 625 RICHEDIT5 oTCode VAR cTCode OF oDlg SIZE 600, 410 ; // w h
FONT oFont PIXEL HSCROLL // HIGHLIGHT ( bad )

// -----------------

FUNCTION SHOWMEMO(oTCode, cTCode, cTFilter)
LOCAL cStr :="", cChange := cTFilter // Word that we will look for
LOCAL cInto := "\cf2 " + cTFilter + " \cf1" // Put Word in Color

cStr += "{\rtf1\ansi\deff0"
cStr += "{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}"
cstr = cStr + cTCode
cStr += "}"
cShowStr = StrTran( cStr, cChange, cInto )
oTCode:SetText( cShowStr )

RETURN NIL




regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sun Feb 25, 2018 04:43 AM
ukoenig wrote:Cristobal,

printing on multiple pages works but I didn't use pagebreak.

Next I want to show colored keywords.
I think it is not tested showing / refresh a new text on xbrowse row-change.
Adding HIGHLIGHT is giving a terrible effect :
the complete dialog is < fllckering / refreshed > on row-change and the display slows down.
I think using it on a standalonetext it doesn't matter but not for a fast text-changing with xBrowse.

@ 40, 625 RICHEDIT5 oTCode VAR cTCode OF oDlg SIZE 600, 410 ; // w h
FONT oFont PIXEL HSCROLL HIGHLIGHT :-)

with my next release I can include the normal and a version with activated highlight

maybe there is another solution possible

NO bad effects using :

Colorize( nStart, nEnd, nColor )

regards
Uwe :-)


Please try with this code

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "RichEdi5.ch"

Static oDlg
Static oBrw
Static oMemo

function Main()

聽 local cTitle:="Test"
聽 local cResult
聽 local oFont, oBold
聽 local oSay

聽 REQUEST DBFCDX

聽 聽USE clients via "DBFCDX" NEW

聽 聽DEFINE FONT oFont NAME "Courier New" SIZE 8,15
聽 聽DEFINE FONT oBold NAME "Courier New" BOLD SIZE 8,15

聽 聽DEFINE DIALOG oDlg FROM 5,10 TO 50, 170 font oFont TITLE "Test Color"

聽 聽@ 10, 10 XBROWSE oBrw OF oDlg ;
聽 聽 聽 SIZE 350, 200 PIXEL ;
聽 聽 聽 COLUMNS 'Name', 'Adress', 'Notes' ;
聽 聽 聽 ALIAS 'CLIENTS' NOBORDER

聽 聽WITH OBJECT oBrw

聽 聽 聽 :nColDividerStyle := LINESTYLE_LIGHTGRAY
聽 聽 聽 :nRowDividerStyle := LINESTYLE_LIGHTGRAY
聽 聽 聽 :bClrRowFocus 聽 聽 := { || { CLR_BLACK, RGB(185,220,255) } }
聽 聽 聽 :nMarqueeStyle 聽 聽:= MARQSTYLE_HIGHLROWMS

聽 聽 聽 :bChange := { || oSay:refresh(),showmemo() }

聽 聽 聽 :CreateFromCode()
聽 聽END

聽 聽@ 10,370 SAY oSay PROMPT clients->notes SIZE 200, 80 PIXEL OF oDlg COLOR CLR_BLACK update 聽//TRANSPARENT

聽 聽ACTIVATE DIALOG oDlg CENTERED ON INIT showmemo()

聽 聽close all

Return nil

function showmemo()

聽 聽Local cStr 聽 聽 := ""
聽 聽local cChange 聽:= "FiveWin" 聽 // 聽Word that we will look for
聽 聽local cInto 聽 聽:= "\highlight1 FiveWin \highlight0" 聽// Put Word in Color
聽 聽local cText
聽 聽local cVar 聽 聽 := ""

聽 聽cText 聽 := clients->notes

聽 聽cStr 聽 聽+= "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang3082{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}"
聽 聽cStr 聽 聽+= "{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;\red128\green64\blue64;\red0\green0\blue128;}"
聽 聽cStr 聽 聽+= "\viewkind4\uc1"
聽 聽cStr 聽 聽+= "\pard\fs20" + if( Empty( cText ), " ", cText )
聽 聽cStr 聽 聽+= "}"
聽 聽cStr 聽 聽:= StrTran( cStr, cChange, cInto )

聽 聽if hb_Isnil( oMemo )
聽 聽 聽 @ 180,740 RICHEDIT5 oMemo VAR cVar of oDlg PIXEL SIZE 450, 400 HIGHLIGHT
聽 聽endif
聽 聽oMemo:LoadRTF( cStr, .F. )

return NIL
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sun Feb 25, 2018 09:39 AM

Cristobal ,

thank You very much.
With these changes it looks much better now :shock:
It will be next on my todolist.
I would like to add a button to show the sample from the memofield
in fullscreen-mode with a editor.
Just using wordpad or do You have a better idea ?

regards
Uwe :D

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: A sample to print with REPrintBox5 a memo on two pages ?
Posted: Sun Feb 25, 2018 10:25 AM

Uwe,

Maybe a launce for a ceartin application like :

c:\multi\multiedit sample.prg (from browse) ?

Ofcource, a copy paste from a other solution will work also ))

Just a idea.

Marc Venken

Using: FWH 23.08 with Harbour