Page 1 of 2
Richedit( ) function problems
Posted: Fri Jun 24, 2016 5:39 pm
by TimStone
Many months ago you created a Richedit function and more recently you modified the class. This may have broken elements of the function. In this example:
cTitle := "Test Rich Edit Function"
cText := "this is a test line of the rich edit function. It should be editable very easily"
RichEdit( @cText, cTitle, 0,0,40,200 )
Using this sequence, the following is happening
1) After making changes, and exiting the function, the changes are not saved to a memo field.
2) The icons for position ( left, center, right ), and those that follow on the button bar, are not displaying. The buttons are there but no bitmap display
I thought about using the elements of the new class, but for documentation it says to local at a sample code piece that is very confusing and uses far more than a richedit text
1) Can we get the function fixed so it returns the cText to be saved in a memo field ?
2) Using the PRINT class, can you show me a sample of keeping RTF formatting when printing using @ Row, Column print syntax ( just like I do with a normal memo field )
3) Can we recall and display the RTF in PREVIEW mode ( PRINT class ), and in normal edit field display
4) Can we use the new class with an RC file ( once again, @ x,y syntax doesn't help out with a .rc controlled dialog ).
Re: Richedit( ) function problems
Posted: Fri Jun 24, 2016 11:58 pm
by cnavarro
Tim, last version not modified class TRichedit, new class TRichEdit5 developed and included
Function RichEdit(), not modified in last version, and continue use old version class TRichEdit
Regards
Re: Richedit( ) function problems
Posted: Sat Jun 25, 2016 12:00 am
by TimStone
OK, but still, the function I described is not fully functional. I've shown the code and noted the problems.
Re: Richedit( ) function problems
Posted: Sat Jun 25, 2016 6:43 am
by Silvio.Falconi
wich error you have?
Re: Richedit( ) function problems
Posted: Sat Jun 25, 2016 6:48 am
by TimStone
Please read the first post in this thread.
Re: Richedit( ) function problems
Posted: Sat Jun 25, 2016 8:12 am
by Silvio.Falconi
Tim
for the old trichedit class
> the changes are not saved to a memo field.
this is a problem I wrote two mounth ago also to Cristobal
Before it run (2002) ok
then Someone changed the save of rtf into Memofile and something not run ok
I would like to make it clear to this someone who should put things as they were and RTF files should be saved to a RTF file and a memo file to a memo file
if the RTF file is stored on a memo file creates the error.
Now I'm trying some functions Reinaldo Reinaldo perhaps has found the solution
because it seems that the function resavefile work good
Re: Richedit( ) function problems
Posted: Sat Jun 25, 2016 8:51 am
by Antonio Linares
Tim,
The function RichEdit() was not saving changes previously. In order to save them these changes
are required in memoedit.prg:
Remove static function Save() and modify these lines
static function BuildRichEditBar( oWnd, oRtf, bSave )
...
DEFINE BUTTON oBtn OF oBar ;
MESSAGE "Save a file" TOOLTIP "Save" NOBORDER ;
ACTION If( ! Empty( bSave ), Eval( bSave, oRtf:SaveAsRTF() ),)
...
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( BuildRichEditBar( oDlg, oMemo, { | c | cText := c } ), oDlg:ReSize() )
The missing bitmaps are not yet implemented. For now you have to provide these resources
yourself: "Left", "Center", "Right", "Justify", "Number", "Bullet" and "Exit"
These changes will be included in next FWH 16.05
Re: Richedit( ) function problems
Posted: Tue Jun 28, 2016 4:31 pm
by TimStone
I made the changes ... tried it ... but it's not really going to resolve my problem.
Here is what I want to do. I have some text stored in .fpt memo fields. I want to bring it up in a Rich Text editor, Format it, then save it back to the .fpt file. Then, I want it to print on the final document ( invoice ) in it's modified form. When I bring it up on the screen, I want to also see it in the rich text format.
Do we have a simple sample that shows this created within a dialog ?
Re: Richedit( ) function problems
Posted: Tue Jun 28, 2016 5:54 pm
by Antonio Linares
Tim,
Your example with my changes is working fine. What problems do you get ?
cTitle := "Test Rich Edit Function"
cText := "this is a test line of the rich edit function. It should be editable very easily"
RichEdit( @cText, cTitle, 0,0,40,200 )
You have to press the save button in order to save the changes. The saved text is RTF format,
so it can be directly stored in your field.
Re: Richedit( ) function problems
Posted: Tue Jun 28, 2016 5:59 pm
by Antonio Linares
I tested your example this way:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local cTitle := "Test Rich Edit Function"
local cText := "this is a test line of the rich edit function. It should be editable very easily"
RichEdit( @cText, cTitle )
MsgInfo( cText )
return nil
Re: Richedit( ) function problems
Posted: Tue Jun 28, 2016 6:07 pm
by Antonio Linares
I have modified function RichEdit() this way so we can know if the text was "saved":
Code: Select all | Expand
function RichEdit( cText, cTitle, nTop, nLeft, nBottom, nRight )
local oFont, oDlg, oMemo
local hDLL
local uTemp := If( ! Empty( cText ), cText, '' )
local lRich := .F., lGTF := .F., lSaved := .F.
DEFAULT nTop := 9, nLeft := 9, nBottom := 27, nRight := 71.5,;
cTitle := "RichEdit"
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -10
DEFINE DIALOG oDlg FROM nTop, nLeft TO nBottom, nRight ;
TITLE cTitle FONT oFont
oDlg:lTruePixel := .f.
hDLL = LoadLibrary( 'riched20.dll' )
@ 30, 3 RICHEDIT oMemo VAR uTemp OF oDlg PIXEL SIZE 200, 200
oDlg:oClient = oMemo
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( BuildRichEditBar( oDlg, oMemo,;
{ | c | lSaved := .T., cText := c } ), oDlg:ReSize() )
oFont:End()
if hDLL != nil
FreeLibrary( hDLL )
endif
return lSaved
You can test it this way:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local cTitle := "Test Rich Edit Function"
local cText := "this is a test line of the rich edit function. It should be editable very easily"
while RichEdit( @cText, cTitle )
MsgInfo( cText )
end
return nil
It will remain editing the text meanwhile you save it
Re: Richedit( ) function problems
Posted: Tue Jun 28, 2016 10:09 pm
by TimStone
OK ... so I use the function, and I take the first 10 words of the text and make them bold.
MsgInfo now shows the text this way:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 ARIAL;}}
\viewkind4\uc1\pard\b\f0\fs20 I, the Registered Owner hereby authorize the above repair work to be done \b0 along with the necessary materials,
It saved it, but that is what I get instead of I, the Registered Owner hereby authorize the above repair work to be done along with the necessary materials.
Re: Richedit( ) function problems
Posted: Wed Jun 29, 2016 6:03 am
by Antonio Linares
Tim,
What do you get ?
It seems as your msg is uncomplete
Re: Richedit( ) function problems
Posted: Wed Jun 29, 2016 3:25 pm
by TimStone
Antonio,
I took the function and placed it in a "full program". The program actually has disclaimer text used on various documents. These are all stored in memo fields in a .dbf/.fpt file. They are all normally edited with a REDEFINE GET cText MEMO ID 2155 OF oDlg . There is no problem. The full text is quite long ( about 20 lines ).
I would like to format these text items as Rich Text, and then save them back to the memo field when completed. So, I added the following button to do the editing:
DEFINE BUTTON oWBtn2 OF oBarS3 RESOURCE "FEEDIT" ;
ACTION ( RichEdit( @cText, cTitle, 0,0,40,200 ), MsgInfo( cText ) )
The first part of the text is:
I, the Registered Owner hereby authorize the above repair work to be done along with the necessary materials.
After using the editor, in MsgInfo() I should get:
I, the Registered Owner hereby authorize the above repair work to be done along with the necessary materials.
Instead it gives me:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 ARIAL;}}
\viewkind4\uc1\pard\b\f0\fs20 I, the Registered Owner hereby authorize the above repair work to be done \b0 along with the necessary materials,
Re: Richedit( ) function problems
Posted: Wed Jun 29, 2016 9:30 pm
by Antonio Linares
Tim,
You get the text in RTF format. You need to display it in a RichEdit control to see it properly.
In my example I use a loop to show the modified text in the same RichEdit() function