question for trichedit

question for trichedit

Postby Silvio.Falconi » Sun Apr 24, 2016 5: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)



Image


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

Image


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

   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

Image

then I thinked to create this dialog


Image


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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7042
Joined: Thu Oct 18, 2012 7:17 pm

Re: question for trichedit

Postby cnavarro » Sun Apr 24, 2016 8:30 pm

Silvio

4 Question

Image

In TESTRTF.PRG

Code: Select all  Expand view


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

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

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

Re: question for trichedit

Postby cnavarro » Sun Apr 24, 2016 8:49 pm

Silvio, try with

1 Question

Code: Select all  Expand view


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

Re: question for trichedit

Postby Silvio.Falconi » Sun Apr 24, 2016 9: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7042
Joined: Thu Oct 18, 2012 7:17 pm

Re: question for trichedit

Postby Silvio.Falconi » Sun Apr 24, 2016 9:52 pm

cnavarro wrote:Silvio, try with

1 Question

Code: Select all  Expand view


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: Select all  Expand view
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7042
Joined: Thu Oct 18, 2012 7:17 pm

Re: question for trichedit

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

Re: question for trichedit

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

Re: question for trichedit

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

Re: question for trichedit

Postby cnavarro » Sun Apr 24, 2016 10:38 pm

Silvio

2 Question

Modify

Code: Select all  Expand view


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

Re: question for trichedit

Postby Silvio.Falconi » 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: Select all  Expand view

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: Select all  Expand view
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7042
Joined: Thu Oct 18, 2012 7:17 pm

Re: question for trichedit

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], RSalazarU and 46 guests