FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour RTF from Variable
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: RTF from Variable
Posted: Sat May 06, 2017 07:54 PM
Rick, for now, put
Code (fw): Select all Collapse
聽 聽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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: 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 (fw): Select all Collapse
    // 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 (fw): Select all Collapse
    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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: 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 (fw): Select all Collapse
聽 聽 // 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 (fw): Select all Collapse
聽 聽 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: RTF from Variable
Posted: 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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Wed Dec 01, 2021 01: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: RTF from Variable
Posted: Wed Dec 01, 2021 01:14 AM
In TRichEdit5 I have implemented automatic buttonbar. When mouse is moved to top of control, buttonbar is showed
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: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Wed Dec 01, 2021 01: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 (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Thu Dec 02, 2021 01: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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Thu Dec 02, 2021 09: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: RTF from Variable
Posted: 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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Thu Dec 02, 2021 11:45 PM
Here is the simplertf.prg code:

Code (fw): Select all Collapse
// 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 (fw): Select all Collapse
#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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: RTF from Variable
Posted: 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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Fri Dec 03, 2021 01: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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: Fri Dec 03, 2021 05: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 (fw): Select all Collapse
  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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: RTF from Variable
Posted: 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