error in Richedit [bug in FWH]

error in Richedit [bug in FWH]

Postby ukservice » Tue Jan 24, 2012 1:08 pm

Hello,

When I press the button Bold, all text gets selected:
Image

Uploaded with ImageShack.us


I 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 view
#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.
Last edited by ukservice on Wed Jan 25, 2012 3:34 pm, edited 1 time in total.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit

Postby ukservice » Tue Jan 24, 2012 3:01 pm

I forgot .rc file:

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

}
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit

Postby ukservice » Wed Jan 25, 2012 10:43 am

Any idea please?.

Thanks.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit

Postby StefanHaupt » Wed Jan 25, 2012 2:32 pm

It was working fine with older versions of fwh, but not with 11.09 :(
Same with :SetItalic (), :SetUnderline(), ...

It seems to be a bug
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: error in Richedit

Postby ukservice » Wed Jan 25, 2012 3:07 pm

Stefan,

Thanks for helping me.

Antonio, please include the fix in FW 12.01.

Thanks.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit [bug in FWH]

Postby Antonio Linares » Wed Jan 25, 2012 6:27 pm

Stefan, John,

Could you please test FWH\samples\TestRtf.prg ? Here it is working fine with bold, underline, italic, etc...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42087
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: error in Richedit [bug in FWH]

Postby ukservice » Wed Jan 25, 2012 7:35 pm

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.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit [bug in FWH]

Postby Daniel Garcia-Gil » Wed Jan 25, 2012 8:19 pm

Jhon

Code: Select all  Expand view
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 view
ACTION ( lBold := !lBold, ;
                                   oRich:SelectAll(), oRich:SetBold( lBold ), oRich:Setfocus(), sysrefresh(), oRich:SetPos( 0 ) )


it's a bug?
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: error in Richedit [bug in FWH]

Postby ukservice » Wed Jan 25, 2012 8:39 pm

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.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit [bug in FWH]

Postby Antonio Linares » Wed Jan 25, 2012 9:04 pm

John,

You have to select a portion of the text, then change its attributes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42087
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: error in Richedit [bug in FWH]

Postby ukservice » Wed Jan 25, 2012 9:42 pm

Antonio,

I want to set bold for next text, as samples\testrtf does.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: error in Richedit [bug in FWH]

Postby Antonio Linares » Wed Jan 25, 2012 10:23 pm

John,

Try it this way:

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

 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42087
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: error in Richedit [bug in FWH]

Postby Antonio Linares » Wed Jan 25, 2012 10:34 pm

In fact, on a window it behaves different. Why ? I really don't know it...

Code: Select all  Expand view
#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
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42087
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: error in Richedit [bug in FWH]

Postby StefanHaupt » Thu Jan 26, 2012 8:21 am

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
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: error in Richedit [bug in FWH]

Postby ukservice » Thu Jan 26, 2012 5:16 pm

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 view
#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
 
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests