Page 1 of 2
error in Richedit [bug in FWH]
Posted: Tue Jan 24, 2012 1:08 pm
by ukservice
Hello,
When I press the button Bold, all text gets selected:

Uploaded with
ImageShack.usI don´t want this, just continue editing in same position as I was before I press Bold. This is my code:
Code: Select all | Expand
#Include "FiveWin.ch"
//----------------------------------------------------------------------------//
Function Main()
Local oDlg, oRich, cRtf := "test"
Local hRichDLL := LoadLibrary( "riched20.dll" )
local lBold := .F.
cRtf:="{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}"+CRLF+;
"{\colortbl ;\red0\green77\blue187;\red192\green80\blue77;}"+CRLF+;
"{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\cf1\lang1031\f0\fs22 This is \b colored \b0 text\cf0 . \cf2 The background is color 1 and the foreground is color 2\cf0\par"+CRLF+CRLF+;
"}"
DEFINE DIALOG oDlg NAME "Test"
oRich = TRichEdit():Redefine( 100, { || "" }, oDlg )
oRich:SetText( cRtf )
oDlg:bStart = { || oRich:SetPos( 0 )}
REDEFINE BUTTON ID 120 ACTION ( lBold := !lBold, ;
oRich:SetBold( lBold ), oRich:Setfocus() )
ACTIVATE DIALOG oDlg CENTERED
FreeLibrary( hRichDLL )
Return nil
What is wrong?.
Thank you very much.
Re: error in Richedit
Posted: Tue Jan 24, 2012 3:01 pm
by ukservice
I forgot .rc file:
Code: Select all | Expand
#define IDC_EDIT1 101
Test DIALOG 41, 64, 409, 199
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Testing the RichEdit control"
FONT 8, "MS Sans Serif"
{
CONTROL "", 100, "RichEdit20A", 4100 | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 6, 12, 398, 163
PUSHBUTTON "&Load text file", 110, 5, 179, 50, 16
PUSHBUTTON "&Bold", 120, 95, 179, 50, 16
}
Re: error in Richedit
Posted: Wed Jan 25, 2012 10:43 am
by ukservice
Any idea please?.
Thanks.
Re: error in Richedit
Posted: Wed Jan 25, 2012 2:32 pm
by StefanHaupt
It was working fine with older versions of fwh, but not with 11.09
Same with :SetItalic (), :SetUnderline(), ...
It seems to be a bug
Re: error in Richedit
Posted: Wed Jan 25, 2012 3:07 pm
by ukservice
Stefan,
Thanks for helping me.
Antonio, please include the fix in FW 12.01.
Thanks.
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 6:27 pm
by Antonio Linares
Stefan, John,
Could you please test FWH\samples\TestRtf.prg ? Here it is working fine with bold, underline, italic, etc...
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 7:35 pm
by ukservice
Antonio
samples\testrtf works fine but not my sample.
In my sample, when I call setfocus() all text get selected.
Can you please try my sample?.
Thanks.
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 8:19 pm
by Daniel Garcia-Gil
Jhon
Code: Select all | Expand
ACTION ( lBold := !lBold, ;
oRich:SetBold( lBold ), oRich:Setfocus(), sysrefresh(), oRich:SetPos( 0 ) )
but you have select the text first
if you want select all text and convert to BOLD
Code: Select all | Expand
ACTION ( lBold := !lBold, ;
oRich:SelectAll(), oRich:SetBold( lBold ), oRich:Setfocus(), sysrefresh(), oRich:SetPos( 0 ) )
it's a bug?
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 8:39 pm
by ukservice
Daniel,
Thanks for helping me.
I explain myself better.
I type into a new line, for example, hello.
Next, I want world in bold, so I press Bold button so as to write world in bold. Instead, I get all text selected as showed in picture.
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 9:04 pm
by Antonio Linares
John,
You have to select a portion of the text, then change its attributes
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 9:42 pm
by ukservice
Antonio,
I want to set bold for next text, as samples\testrtf does.
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 10:23 pm
by Antonio Linares
John,
Try it this way:
Code: Select all | Expand
#Include "FiveWin.ch"
//----------------------------------------------------------------------------//
Function Main()
Local oDlg, oRich, cRtf
Local hRichDLL := LoadLibrary( "riched20.dll" )
local lBold := .F., nPos := 0
cRtf:="{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}"+CRLF+;
"{\colortbl ;\red0\green77\blue187;\red192\green80\blue77;}"+CRLF+;
"{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\cf1\lang1031\f0\fs22 This is \b colored \b0 text\cf0 . \cf2 The background is color 1 and the foreground is color 2\cf0\par"+CRLF+CRLF+;
"}"
DEFINE DIALOG oDlg NAME "Test"
oRich = TRichEdit():Redefine( 100, "", oDlg )
oRich:SetText( cRtf )
oRich:bGotFocus = { || oRich:HideSel(), oRich:SetSel( nPos, nPos ) }
oRich:bLostFocus = { || nPos := oRich:GetPos() }
REDEFINE BUTTON ID 120 ACTION ( lBold := ! lBold, ;
oRich:SetBold( lBold ), oRich:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
FreeLibrary( hRichDLL )
Return nil
Re: error in Richedit [bug in FWH]
Posted: Wed Jan 25, 2012 10:34 pm
by Antonio Linares
In fact, on a window it behaves different. Why ? I really don't know it...
Code: Select all | Expand
#include "FiveWin.ch"
#include "RichEdit.ch"
//----------------------------------------------------------------------------//
Function Main()
local oWnd, oRE, cText := "", lBold := .F.
Local hRichDLL := LoadLibrary( "riched20.dll" )
DEFINE WINDOW oWnd
@ 1, 1 RICHEDIT oRE VAR cText SIZE 400, 200
@ 1, 70 BUTTON "Bold" SIZE 60, 15 ACTION ( oRE:SetBold( lBold := ! lBold ), oRE:SetFocus() )
ACTIVATE WINDOW oWnd
FreeLibrary( hRichDLL )
Return nil
Re: error in Richedit [bug in FWH]
Posted: Thu Jan 26, 2012 8:21 am
by StefanHaupt
I made some test with different styles, but no change. It´s really curious.
The last sample of Antonio at least is a workaround to change selected text to bold. John´s intention to click the buton and write the next word bold does not work in dialogs
Re: error in Richedit [bug in FWH]
Posted: Thu Jan 26, 2012 5:16 pm
by ukservice
Antonio,
Thanks for helping. Now the sample does not select all text, but if I start typing my name and next I press Bold and I type John, John is not in bold.
What is wrong?.
Thanks again.
Code: Select all | Expand
#Include "FiveWin.ch"
#include "richedit.ch"
//----------------------------------------------------------------------------//
Function Main()
Local oDlg, oRich, cRtf
Local hRichDLL := LoadLibrary( "riched20.dll" )
local lBold := .F., nPos := 0
cRtf:="{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}"+CRLF+;
"{\colortbl ;\red0\green77\blue187;\red192\green80\blue77;}"+CRLF+;
"{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\cf1\lang1031\f0\fs22 This is \b colored \b0 text\cf0 . \cf2 The background is color 1 and the foreground is color 2\cf0\par"+CRLF+CRLF+;
"}"
DEFINE DIALOG oDlg NAME "Test"
REDEFINE RICHEDIT oRich VAR cRTF OF oDlg ID 100
REDEFINE BUTTON ID 120 ACTION ( lBold := ! lBold, ;
oRich:SetBold( lBold ), oDlg:Update(), oRich:SetFocus(), oDlg:cTitle := "IsBold "+cValtoChar(lBold) )
oRich:SetText( cRtf )
oRich:bGotFocus = { || oRich:HideSel(), oRich:SetSel( nPos, nPos ) }
oRich:bLostFocus = { || nPos := oRich:GetPos() }
ACTIVATE DIALOG oDlg CENTERED
FreeLibrary( hRichDLL )
Return nil