RTF from Variable

Re: RTF from Variable

Postby cnavarro » Sat May 06, 2017 7:54 pm

Rick, for now, put
Code: Select all  Expand view

   oRich:bGotFocus = { || oRich:SetSel( 0, 0 ) }
 


After REDEFINE RICHEDIT5
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: RTF from Variable

Postby TimStone » Wed Dec 01, 2021 12:12 am

I would like to bring back this thread in case changes to FWH may have modified this. Here is my testing and result:

I use the following control:

Code: Select all  Expand view

    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cRTF ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  //UPDATE
       
    oRich:SetText( cText ) 

 


And in my .RC file:

Code: Select all  Expand view

    CONTROL         "", 2155, "RichEdit50W", 4100 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 10, 40, 500, 350
 


cText is loaded from a .dbf memo field.

Using a GET with MemoEdit, cText has data.

Using this contol, I get a blank control box. If I right click, I am given an option to turn on/off the spell checker. I see no Rich Edit controls so no other capability is displayed.

I followed the discussion in this thread and I'm not sure if there was a final resolution.

PLEASE - I use .rc files so suggestions us @x,y control are NOT an option.

Input on how to get this to work properly would be appreciated.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby TimStone » Wed Dec 01, 2021 12:12 am

I would like to bring back this thread in case changes to FWH may have modified this. Here is my testing and result:

I use the following control:

Code: Select all  Expand view

    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cRTF ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  //UPDATE
       
    oRich:SetText( cText ) 

 


And in my .RC file:

Code: Select all  Expand view

    CONTROL         "", 2155, "RichEdit50W", 4100 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 10, 40, 500, 350
 


cText is loaded from a .dbf memo field.

The text will load. If I right click, I am given an option to turn on/off the spell checker. I see no Rich Edit controls so no other capability is displayed. Also, can we auto turn on the spell checker by default ?

I followed the discussion in this thread and I'm not sure if there was a final resolution.

PLEASE - I use .rc files so suggestions us @x,y control are NOT an option.

Input on how to get this to work properly would be appreciated.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby cnavarro » Wed Dec 01, 2021 12:29 am

Try with
oRtf:LoadRTF( cText )

in ON INIT clause of ACTIVATE DIALOG
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: RTF from Variable

Postby TimStone » Wed Dec 01, 2021 1:06 am

That is not working. It gives me a blank screen.

I get the text displayed. We know that the control is working because a right click gives me the option to turn on spelling.

What I don't get is the editing toolbar with the RichText options. Without that, it's just memo edit.

So loading text happens. The spell check option ( though limited ) works. I just have no formatting controls.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby cnavarro » Wed Dec 01, 2021 1:14 am

In TRichEdit5 I have implemented automatic buttonbar. When mouse is moved to top of control, buttonbar is showed
Image
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: RTF from Variable

Postby TimStone » Wed Dec 01, 2021 1:59 am

I saw that in FiveDBU, but that does not happen in this example.

Please look at the RC control I entered. Is that the correct current value for the control ?

I know the RTF capability is working because it does engage the spell checker. But, it does not show the button bar.

Here is the full code for the Dialog. Please note that this has a "forced load" temporarily for testing purposes.

Code: Select all  Expand view


FUNCTION setup3
    // Text Editor for disclosures
    //  Updated:    7/30/2015 5:55:48 PM
   
    LOCAL oEndText, oDlg, nRcrd, oRich
    PRIVATE cText := " ", cTitle := " ", cRtf := " "
   
    // Open the text database
    oEndText := tEndText():New( )
    oEndText:gobottom( )
    nRcrd := oEndText:recno( )
    DO WHILE nRcrd < 8
        oEndText:append( )
        oEndText:skip( )
        nRcrd := oEndText:recno( )
    ENDDO
    oEndText:gotop( )

  cText := oEndText:tagtext

    // Create the dialog
    DEFINE DIALOG oDlg RESOURCE "SETUP3" BRUSH oBrush transparent OF oWnd
    oDlg:nHelpID := 6

    REDEFINE BUTTONBAR oBarS3 ID 100 SIZE 60,60 OF oDlg 2015
            oBarS3:bClrGrad := aPubGrad

    MENU oWPopS1 POPUP
       
    MENUITEM "Estimate" ACTION ( oEndText:goto(1), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
        oDlg:update() ) MESSAGE "Text to print on estimates"
     
        MENUITEM "Invoices" ACTION ( oEndText:goto(2), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Text to print on invoices"
   
        MENUITEM "Tag lines" ACTION ( oEndText:goto(3), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Ad tag lines to printed on invoices"

        MENUITEM "Counter" ACTION ( oEndText:goto(4), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Text to print on counter sales"

        MENUITEM "Worksheets"   ACTION ( oEndText:goto(5), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Text to print on worksheets"

      MENUITEM "Statements" ACTION ( oEndText:goto(6), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
        oDlg:update() ) MESSAGE "Text to print on statements"

        MENUITEM "Recommendation"   ACTION ( oEndText:goto(7), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Disclosure for recommendation"

        MENUITEM "Text Message"     ACTION ( oEndText:goto(8), cText := oEndText:tagtext, cTitle := oEndText:texttype, ;
            oDlg:update() ) MESSAGE "Signature line for text messages"

       
    ENDMENU

    DEFINE BUTTON oWBtn1 OF oBarS3 RESOURCE "FIBILD" PROMPT "Sections" ;
        ACTION  oWBtn1:ShowPopup() MENU oWPopS1 TOOLTIP "Text sections"  
           
    DEFINE BUTTON oWBtn3 OF oBarS3 RESOURCE "HRSAVE" ;
        ACTION ( oEndText:tagtext := cText, oEndText:save( ), oDlg:update( ) )

    DEFINE BUTTON oWBtn4 OF oBarS3 RESOURCE "SPELL" ;
        ACTION  ( cText := SpellOne( cText), oDlg:update() )

    DEFINE BUTTON oWBtn5 OF oBarS3 RESOURCE "HREXIT" ;
        ACTION oDlg:end()
/*     
    // Create edit control
    REDEFINE GET cText MEMO ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes" UPDATE
*/


    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cText ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  //UPDATE
       
    oRich:SetText( cText ) 

    ACTIVATE DIALOG oDlg ON INIT (oReBar:hide( ),  oBarS3:lTransparent := .F.) CENTERED

  oReBar:show( )
    // Close the file
    oEndText:close()
   
RETURN NIL
 


And the .rc for this dialog:

Code: Select all  Expand view

SETUP3 DIALOG 0, 0, 660, 410
STYLE WS_POPUP | WS_CAPTION
CAPTION "Text Editor"
{
    CONTROL                 "", 100, "TBar", 0|WS_CHILD|WS_VISIBLE, 0,0, 640, 30
    CONTROL         "", 2155, "RichEdit50W", 4100 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 10, 40, 500, 350
}
 


Built with FWH 21.11, Harbour 32 bit, Microsoft Visual Studio Community 2022
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby TimStone » Thu Dec 02, 2021 1:14 am

Did you get a chance to test this out yet ? See my last note.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby TimStone » Thu Dec 02, 2021 9:32 pm

Crystobal,

In looking at the source code in 21.11 FWH, I see that you included the lBar option with the COMMAND structure, but did not put that option into the REDEFINE option ( for use with a resource ). Consequently, we do not get the RTF 5 controls.

Do you have a later version that was not included in the new FWH distribution that enables this feature within a resource, or was in not a workable option ?

Thanks.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby cnavarro » Thu Dec 02, 2021 10:04 pm

Tim
If you prepare a small self-contained example of a dialog with a REDEFINED RichEdit control, I can see if it is possible to integrate the BAR CONTROL.
Simple dialog with a REDEFINED RICHEDIT, only, please
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: RTF from Variable

Postby TimStone » Thu Dec 02, 2021 11:45 pm

Here is the simplertf.prg code:

Code: Select all  Expand view

// Provide for include files
#include "fivewin.ch"
#INCLUDE "richedi5.ch"


PROCEDURE main
    // Text Editor with resource for RTF5
   
    LOCAL oDlg, oRich,  cText := " "
   
  cText := "This is a test of the RTF 5 editor using a resource file.  It does not yet display the Rich Text editing bar"

    // Create the dialog
    DEFINE DIALOG oDlg RESOURCE "SIMPLERTF"
    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cText ID 100 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  
       

    ACTIVATE DIALOG oDlg

RETURN NIL
 


And the simplertf.rc

Code: Select all  Expand view

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
 
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

SIMPLERTF DIALOG 0, 0, 660, 410
STYLE DS_MODALFRAME | WS_SYSMENU | WS_CAPTION
CAPTION "Text Editor"
{
    CONTROL         "", 100, "RichEdit50W", 4100 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 10, 40, 500, 350
}
 


I built it with buildh32.bat in the FWH\samples folder. It runs, but without the bar as previously noted.

I built with FWH 21.11, Harbour 32 bit, MSVC 2022 ( Visual Studio Community 2022 )

I look forward to hearing about your success.;
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby cnavarro » Fri Dec 03, 2021 12:41 am

Tim, look your mail.
Done
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: RTF from Variable

Postby TimStone » Fri Dec 03, 2021 1:10 am

Unfortunately Outlook blocked the .prg files and I can't get them.

Can you resend in a zip ? Thank you so much.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby TimStone » Fri Dec 03, 2021 5:52 pm

Thank you. One more question:

Can you point me to a reference for printing RTF5 text using the FWH printer class. Here is an example of what I would replace. It is text, saved from a memofield, that holds "disclaimers".

Code: Select all  Expand view

  FOR lx := 1 TO MLCount( oEndText:tagtext, 120,, .T. )
      WOPAGEHEAD( oPrn, aHead )
      IF lPrintColor
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond, , CLR_RED )
      ELSE
         oPrn:SayText( nRow, 2 * nCsp, MemoLine( oEndText:tagtext, 120, lx,, .T. ),nCsp*120, nRsp * 1.1, oFcond )
      ENDIF
      nRow += nRsp
   NEXT

 


I believe I would need a replacement for :SayText( ) and/or MemoLine( ) that substitutes the RTF. Size and color could be eliminated and provided through the RTF I believe. Thus, this would be a single text block, put in a defined space, on a printout.

I found a sample for the report class, but I use custom reports designed strictly with the FWH Printer class.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: RTF from Variable

Postby TimStone » Fri Dec 03, 2021 11:00 pm

Steps:

1). Obtain text from a memo field in a .dbf file ( CDX ) and save as a variable
2). Open the variable in RICHEDIT5 control.
3). Make changes to the variable
4). Save the variable to the memo file

Though I can edit and see changes on the RICHEDIT5 control, thus knowing the text in the variable has changed, I cannot then save that variable back to the memo file. There is no error, just no save of the modified value.

I assume the value in RichEdit is in a buffer for editing. Looking at the current .prg for RICHEDIT5 ( that you just sent ), the Save control seems to write the value into a string, called bSave. However, in the example, bSave is not passed to the control, so there is no save.

So,taking the example we are working with above, if cText is derived from a database ( memo field ), after editing the value, what do I need to do to be sure I'm able to save the changed text back to that Memo field in RTF ?

I searched but can't find documentation or comments on this step.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests