FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour question for trichedit
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
question for trichedit
Posted: Sun Apr 24, 2016 05:41 PM
Dear Antonio (or dear all)


I wish as U some questions on trichedit class only 8 small question ...



because I need it for a application and I compiled the testrtf,prg to see what I have and I rewrite a small rtfpad (from testrtf.prg)






I add a second bar down the first and not when I open a file rtf ( as testrtf.prg)




1. question

on testrtf.prg there is a save function


Code (fw): Select all Collapse
static function Save()

聽 聽local cFile := cGetFile( "Rich Text Format (*.rtf) |*.rtf|" + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Only Text Format (*.txt) |*.txt", ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Please write a filename", nGetFileFilter(),, .t. )

聽 聽if !Empty( cFile )
聽 聽 聽 cFile := Upper( cFile ) + If( ! "." $ cFile, If( nGetFileFilter() == 1, ".RTF", ".TXT" ), "" )

聽 聽 聽 oRTF:SaveToRTFFile( cFile )
聽 聽 聽 oRTF:SetClear()
聽 聽endif

return nil


the file can be txt or rtf

cFile := Upper( cFile ) + If( ! "." $ cFile, If( nGetFileFilter() == 1, ".RTF", ".TXT" ), "" )


but on tichedit class I not found the possibility to set the format of the file

on include there are also

#define SF_TEXT 1
#define SF_RTF 2

but I not found any sample on testrtf to use or save a rtf file into txt

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 Question


I wish create a lines as this picture




and on testrtf.rtf I found also there is the possibility to insert also Hyperlink but I not found the methods on trichedit class



I thinked to create these new methods

seeing the METHOD SetAttribute on trichedit class

Code (fw): Select all Collapse
聽 聽METHOD SetAttribute2( lUpp, lSup, lSub, lOnOff )
聽 聽METHOD SetUpperCaps( lOnOff ) INLINE ::SetAttribute2( .T.,,,,, 聽lOnOff )
聽 聽METHOD SetSupScript( lOnOff ) INLINE ::SetAttribute2( , .T.,,,, lOnOff )
聽 聽METHOD SetSubScript( lOnOff ) INLINE ::SetAttribute2( ,, .T.,,, lOnOff )
聽 聽METHOD SetHiddenTxt( lOnOff ) INLINE ::SetAttribute2( ,,, .T.,, lOnOff )
聽 聽METHOD SetHyperLink( lOnOff ) INLINE ::SetAttribute2( ,,,, .T., lOnOff )




METHOD SetAttribute2( lUpper, lSuper, lSub, lHidden, lLink, lOnOff ) CLASS TRichEdit

聽 聽LOCAL nMask, nEffects

聽 聽DEFAULT lUpper 聽:= .F., ;
聽 聽 聽 聽 聽 聽lSuper 聽:= .F., ;
聽 聽 聽 聽 聽 聽lSub 聽 聽:= .F., ;
聽 聽 聽 聽 聽 聽lHidden := .F., ;
聽 聽 聽 聽 聽 聽lLink 聽 := .F., ;
聽 聽 聽 聽 聽 聽lOnOff 聽:= .T.

聽 聽if ( lUpper .or. lHidden ) .and. ! ::lRE30
聽 聽 聽 RETURN NIL
聽 聽endif

聽 聽nMask := nOr( If( lUpper, 聽CFM_ALLCAPS, 聽 聽 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽If( lSuper, 聽CFM_SUPERSCRIPT, 0 ), If( lSub, 聽CFM_SUBSCRIPT, 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽If( lHidden, CFM_HIDDEN, 聽 聽 聽0 ), If( lLink, CFM_LINK, 聽 聽 聽0 ) )

聽 聽nEffects := nOr( If( lUpper, 聽CFE_ALLCAPS, 聽 聽 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If( lSuper, 聽CFE_SUPERSCRIPT, 0 ), If( lSub, 聽CFE_SUBSCRIPT, 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If( lHidden, CFE_HIDDEN, 聽 聽 聽0 ), If( lLink, CFE_LINK, 聽 聽 聽0 ) )

聽 聽RESetAttribute2( ::hWnd, nMask, nEffects, lOnOff )

RETURN NIL


then I not found RESetAttribute( ::hWnd, nMask, nEffects, lOnOff ) to make RESetAttribute2( ::hWnd, nMask, nEffects, lOnOff )

perhaps Antonio can Help us

---------------------------------------------------------------------------------------------------------------------------------------------

3 Question


I wish set the paragraph of the text but I not found a sample into testrtf.prg
but I found some methods :

aIndent := ortf:GetIndent() give me the left , right and first line ( izquierda,derecha,primeralinea)

ortf:GetParagraph() give me two parametes before and after

ortf:GetAlign() give me the type of align


On winword I have this dialog



then I thinked to create this dialog





with ortf:GetParagraph() I have two parameters but I need the spaces I found (tab spaces) how I can make ?


---------------------------------------------------------------------------------------------------------------------------------------------

4 Question


I found on testrtf.prg the find function
ok . I can find a word but...

how I can replace a word with another ?
and if I must replace all same words with another ?

wich is the method make it ?

I need it also to make a procedure of merge with fields from a dbf



---------------------------------------------------------------------------------------------------------------------------------------------

5 Question


I can change the color of the text with ortf:SetTextColor( ChooseColor( ncolor ) )


but I not have the ncolor current of the text how I can found it ?


---------------------------------------------------------------------------------------------------------------------------------------------

6 Question


When I open a rtf file ( as you can see on first picture of this message ) I see the file into the window main

but how I can show the file as our rpreview ( type printer layout ) as we see it on winword or wordpad application ?



---------------------------------------------------------------------------------------------------------------------------------------------

7 Question


I remember there was a function called SHFileProperty() and I found also a sample on .\samples of fwh

I need it to show the property of the file from rtfpad , why this function there was not on new fwh release ?



---------------------------------------------------------------------------------------------------------------------------------------------

8 Question

How I can insert object into rtfile sample I need to insert tables or excel or another object from a extern application ?




thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: question for trichedit
Posted: Sun Apr 24, 2016 08:30 PM
Silvio

4 Question



In TESTRTF.PRG

Code (fw): Select all Collapse
static function SetChildBar( oWnd )

.../...

聽 聽DEFINE BUTTON RESOURCE "Find" OF oBar GROUP ;
聽 聽 聽 聽 聽 MESSAGE "Search" TOOLTIP "Search" NOBORDER ;
聽 聽 聽 聽 聽 ACTION ( Find(), oRTF:SetFocus() )

聽 聽DEFINE BUTTON RESOURCE "Find" OF oBar GROUP ; 聽// I used the same resource Find
聽 聽 聽 聽 聽 MESSAGE "Replace" TOOLTIP "Replace" NOBORDER ;
聽 聽 聽 聽 聽 ACTION ( Replace(), oRTF:SetFocus() )

.../...


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

static function Replace()

聽 聽local cFind 聽 聽:= Space( 100 )
聽 聽local cReplace := Space( 100 )
聽 聽local nDir 聽 聽 := 1
聽 聽local lCase 聽 聽:= .F.
聽 聽local lWord 聽 聽:= .T.
聽 聽local lAll 聽 聽 := .F.
聽 聽local oDlg
聽 聽local oFind
聽 聽local oReplace

聽 聽DEFINE DIALOG oDlg RESOURCE "Replace"

聽 聽REDEFINE GET oFind 聽 聽VAR cFind 聽 聽ID 101 OF oDlg UPDATE
聽 聽REDEFINE GET oReplace VAR cReplace ID 111 OF oDlg UPDATE

聽 聽REDEFINE RADIO nDir ID 102, 103 OF oDlg

聽 聽REDEFINE CHECKBOX lCase ID 104 OF oDlg
聽 聽REDEFINE CHECKBOX lWord ID 105 OF oDlg
聽 聽REDEFINE CHECKBOX lAll 聽ID 106 OF oDlg

聽 聽REDEFINE BUTTON ID 201 ACTION ( ; //oRTF:SetFocus(), ;
聽 聽 聽 聽 聽if( !lAll, ;
聽 聽 聽 聽 聽 聽 if( oRTF:Find( Trim( cFind ), ( nDir == 1 ), lCase, lWord ),;
聽 聽 聽 聽 聽 聽 聽 聽 oRTF:ReplaceSel( , Trim( cReplace ) ), MsgInfo( "Text not Found" ) ) ,;
聽 聽 聽 聽 聽 聽 聽 聽 oRTF:ReplaceAll( , Trim( cFind ), ( nDir == 1 ), lCase, lWord, lAll, Trim( cReplace ) ) ) )

聽 聽REDEFINE BUTTON ID 202 ACTION ( oDlg:End() )

聽 聽oDlg:bStart := { || oDlg:SetFocus() }

聽 聽ACTIVATE DIALOG oDlg CENTER NOWAIT

return nil

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


In TRICHEDI.PRG

Code (fw): Select all Collapse
CLASS TRichEdit FROM TControl
.../...
聽 聽METHOD ReplaceAll( 聽lUndo, cFind, lDown, lCase, lWord, lAll, cText 聽)
.../...
ENDCLASS


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

METHOD ReplaceAll( lUndo, cFind, lDown, lCase, lWord, lAll, cText ) CLASS TRichEdit
聽 聽
聽 聽local 聽 lSw 聽 := .T.
聽 聽local 聽 nV 聽 聽:= 0
聽 聽local 聽 nPos 聽:= ::GetPos()
聽 聽
聽 聽DEFAULT lUndo := .T.

聽 聽Do While lSw
聽 聽 聽 lSw := ::Find( cFind, lDown, lCase, lWord )
聽 聽 聽 if lSw
聽 聽 聽 聽 聽nV++
聽 聽 聽 聽 聽::ReplaceSel( lUndo, cText )
聽 聽 聽 endif
聽 聽Enddo
聽 聽if !Empty( nV )
聽 聽 聽 MsgInfo( "End Replace: " + StrZero( nV, 5 ) + " found" )
聽 聽else
聽 聽 聽 MsgInfo("String not found: " + cFind )
聽 聽endif
聽 聽::SetPos( nPos )

return if( !Empty( nV ), .T., .F. )

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


In TESTRTF.RC

Code (fw): Select all Collapse
REPLACE DIALOG 34, 96, 315, 141
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Replace"
FONT 8, "MS Sans Serif"
{
聽GROUPBOX "", -1, 10, 10, 224, 121, BS_GROUPBOX | WS_GROUP
聽LTEXT "Replace:", -1, 21, 17, 46, 9
聽EDITTEXT 101, 21, 28, 202, 13
聽LTEXT "With:", -1, 21, 48, 46, 9
聽EDITTEXT 111, 21, 59, 202, 13
聽GROUPBOX "&Direcci贸n:", -1, 21, 77, 74, 37, BS_GROUPBOX | WS_GROUP
聽RADIOBUTTON "Hacia &delante", 102, 30, 88, 56, 9, BS_AUTORADIOBUTTON | WS_TABSTOP
聽RADIOBUTTON "Hacia &atr谩s", 103, 30, 99, 56, 9, BS_AUTORADIOBUTTON | WS_TABSTOP
聽CHECKBOX "Coincidir &may煤sculas y min煤sculas", 104, 104, 88, 120, 9, BS_AUTOCHECKBOX | WS_TABSTOP
聽CHECKBOX "&Palabras completas", 105, 104, 99, 120, 9, BS_AUTOCHECKBOX | WS_TABSTOP
聽CHECKBOX "Re&place All", 106, 104, 110, 120, 9, BS_AUTOCHECKBOX | WS_TABSTOP
聽DEFPUSHBUTTON "&Replace", 201, 244, 14, 62, 15
聽PUSHBUTTON "&Cancelar", 202, 244, 36, 62, 15
聽ICON "Find", -1, 266, 67, 18, 20
}
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: question for trichedit
Posted: Sun Apr 24, 2016 08:49 PM
Silvio, try with

1 Question

Code (fw): Select all Collapse
METHOD SaveToFile( cFileName ) CLASS TRichEdit
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: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: question for trichedit
Posted: Sun Apr 24, 2016 09:32 PM

Cristobal,
run good thanks !!!

only how I can show on rtf the word find (before to recplace)

I thinked to use isselection but not run ...any idea ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: question for trichedit
Posted: Sun Apr 24, 2016 09:52 PM
cnavarro wrote:Silvio, try with

1 Question

Code (fw): Select all Collapse
METHOD SaveToFile( cFileName ) CLASS TRichEdit



Cristobal before pls see the methods METHOD InsertRTF( cRTF ) CLASS TRichEdit and METHOD CanPaste( nFormat )

before there was a new data nFormat ?



I thinked to add a data into trichedit

Data nformat

add nformat on New method and redefine and on some methods

then

Code (fw): Select all Collapse
METHOD LoadRTF( cFile ) INLINE ::cFile name:= cFile, ::nFormat := SF_RTF,  ::LoadFile()
   METHOD LoadTxt( cFile ) INLINE ::cFilename := cFile, ::nFormat := SF_TEXT, ::LoadFile()
   METHOD LoadFile() 


METHOD LoadFile() CLASS TRichEdit

   ::nFormat := If( ::IsRTF( ::cFile ), SF_RTF, SF_TEXT )

   RELoadAsRTF( ::hWnd, cRTF, nFormat )

   ::SetClear()

RETURN NIL

as default on New method
nFormat := SF_RTF, ;

then we can modify SaveToFile method to save rtf and txt i noyt Know how
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: question for trichedit
Posted: Sun Apr 24, 2016 10:32 PM

Silvio

SaveToFile method, use MemoWrite, and not use Methods SaveAsRTF and not use SaveToRTF

I misunderstood what you need?

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: question for trichedit
Posted: Sun Apr 24, 2016 10:34 PM
Silvio.Falconi wrote:Cristobal,
run good thanks !!!

only how I can show on rtf the word find (before to recplace)

I thinked to use isselection but not run ...any idea ?


Silvio

Modify Method Replace

Find all words, and change color or style before replace
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: question for trichedit
Posted: Sun Apr 24, 2016 10:36 PM
Silvio

8 Question

You can not use Copy and Paste?
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: question for trichedit
Posted: Sun Apr 24, 2016 10:38 PM
Silvio

2 Question

Modify

Code (fw): Select all Collapse
METHOD SetAttribute( lBold, lItalic, lUnderline, lStrikeOut, lOnOff, lLink ) CLASS TRichEdit

   local nMask, nEffects

   DEFAULT lBold      := .f., ;
           lItalic    := .f., ;
           lUnderline := .f., ;
           lStrikeOut := .f., ;
           lOnOff     := .t., ;
           lLink      := .f.

   nMask := nOR( If( lBold, CFM_BOLD, 0 ), If( lItalic, CFM_ITALIC, 0 ), ;
                 If( lUnderline, CFM_UNDERLINE, 0 ), ;
                 If( lStrikeOut, CFM_STRIKEOUT, 0 ), ;
                 If( lLink, CFM_LINK, 0 ) )

   nEffects := nOR( If( lBold, CFE_BOLD, 0 ), If( lItalic, CFE_ITALIC, 0 ), ;
                    If( lUnderline, CFE_UNDERLINE, 0 ), ;
                    If( lStrikeOut, CFE_STRIKEOUT, 0 ), ;
                    If( lLink, CFE_LINK, 0 ) )

.../...


ftp://asapdata.arc.nasa.gov/incoming/ro ... RICHEDIT.H
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: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: question for trichedit
Posted: Sun Apr 24, 2016 11:51 PM
I saw but not run ok

on richedit,ch I add

#define CFE_SUBSCRIPT 0x00010000 /* Superscript and subscript are */
#define CFE_SUPERSCRIPT 0x00020000 /* mutually exclusive */
#define CFM_HIDDEN 0x0100
#define CFM_LINK 0x00000020 /* Exchange hyperlink extension */
#define CFM_SUBSCRIPT CFE_SUBSCRIPT | CFE_SUPERSCRIPT
#define CFM_SUPERSCRIPT CFM_SUBSCRIPT

#define CFE_ALLCAPS 0x0080
#define CFM_ALLCAPS 0x0080




on trichedit.prg
I add

Code (fw): Select all Collapse
 
METHOD SetAttribute2( lUpp, lSup, lSub, lOnOff )
聽 聽METHOD SetUpperCaps( lOnOff ) INLINE ::SetAttribute2( .T.,,,,, 聽lOnOff )
聽 聽METHOD SetSupScript( lOnOff ) INLINE ::SetAttribute2( , .T.,,,, lOnOff )
聽 聽METHOD SetSubScript( lOnOff ) INLINE ::SetAttribute2( ,, .T.,,, lOnOff )
聽 聽METHOD SetHiddenTxt( lOnOff ) INLINE ::SetAttribute2( ,,, .T.,, lOnOff )
聽 聽METHOD SetHyperLink( lOnOff ) INLINE ::SetAttribute2( ,,,, .T., lOnOff )



Code (fw): Select all Collapse
 METHOD SetAttribute2( lUpper, lSuper, lSub, lHidden, lLink, lOnOff ) CLASS TRichEdit

聽 聽LOCAL nMask, nEffects

聽 聽DEFAULT lUpper 聽:= .F., ;
聽 聽 聽 聽 聽 聽lSuper 聽:= .F., ;
聽 聽 聽 聽 聽 聽lSub 聽 聽:= .F., ;
聽 聽 聽 聽 聽 聽lHidden := .F., ;
聽 聽 聽 聽 聽 聽lLink 聽 := .F., ;
聽 聽 聽 聽 聽 聽lOnOff 聽:= .T.

聽 聽if ( lUpper .or. lHidden ) .and. ! ::lRE30
聽 聽 聽 RETURN NIL
聽 聽endif

聽 聽nMask := nOr( If( lUpper, 聽CFM_ALLCAPS, 聽 聽 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽If( lSuper, 聽CFM_SUPERSCRIPT, 0 ), If( lSub, 聽CFM_SUBSCRIPT, 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽If( lHidden, CFM_HIDDEN, 聽 聽 聽0 ), If( lLink, CFM_LINK, 聽 聽 聽0 ) )

聽 聽nEffects := nOr( If( lUpper, 聽CFE_ALLCAPS, 聽 聽 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If( lSuper, 聽CFE_SUPERSCRIPT, 0 ), If( lSub, 聽CFE_SUBSCRIPT, 0 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If( lHidden, CFE_HIDDEN, 聽 聽 聽0 ), If( lLink, CFE_LINK, 聽 聽 聽0 ) )

聽 聽RESetAttribute( ::hWnd, nMask, nEffects, lOnOff )

RETURN NIL




for make a test I try to add a menuitem to change a word on uppercase

on testrtf.prg I add on "insert" menu

MENUITEM "&Upper characters" RESOURCE "Upper" ;
MESSAGE "Formats the selection to capital letters (toggle)" ;
ACTION (ortf:SetUpperCaps( .t. ), ;
oRtf:SetFocus() )

and not run !!! I not see the modify then hen I close the window let me say the file is changed !!!
but this is strange because i not see the modify on word
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: question for trichedit
Posted: Mon Apr 25, 2016 12:16 AM

Silvio, I think we should make a unique setAttribute function and include all

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

Continue the discussion