A sample to print with REPrintBox5 a memo on two pages ?

A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Thu Feb 22, 2018 5: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: Select all  Expand view

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
 


Image


regards
Uwe :?:
Last edited by ukoenig on Thu Feb 22, 2018 8:17 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Thu Feb 22, 2018 7: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: Select all  Expand view

oRTF: PageBreak ()
 


Also you have methods and data for you editor
Code: Select all  Expand view


   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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Thu Feb 22, 2018 8: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 ?

Image

regards
Uwe :?:
Last edited by ukoenig on Sat Feb 24, 2018 6:04 pm, edited 2 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Thu Feb 22, 2018 8:25 pm

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

viewtopic.php?f=16&t=6594&p=29464&hilit=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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Thu Feb 22, 2018 8: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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Thu Feb 22, 2018 8: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Thu Feb 22, 2018 8: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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Thu Feb 22, 2018 8: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Thu Feb 22, 2018 8:57 pm

Ok
You have

Code: Select all  Expand view


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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Sat Feb 24, 2018 5: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 :cry:

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 :?:
Last edited by ukoenig on Sat Feb 24, 2018 5:54 pm, edited 2 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby Marc Venken » Sat Feb 24, 2018 5:52 pm

Did you look at this ? Seems to work for Xbrowse

Compile in samples

Code: Select all  Expand view

#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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Sat Feb 24, 2018 6: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 :D

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


Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby cnavarro » Sun Feb 25, 2018 4: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 :cry:

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: Select all  Expand view

#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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby ukoenig » Sun Feb 25, 2018 9: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A sample to print with REPrintBox5 a memo on two pages ?

Postby Marc Venken » 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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1431
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 97 guests