Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RTF-RichTextBox and Highlighting
Message
De
15/08/2006 09:35:03
 
 
À
14/08/2006 18:23:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01145456
Message ID:
01145558
Vues:
207
This message has been marked as the solution to the initial question of the thread.
>I have the following in a commandbutton for a edit control on a richtext (RTF) edit (active-x):
>
>
>LOCAL lcCharFormat, loCharFormat
>DECLARE INTEGER SendMessage IN Win32API INTEGER, INTEGER, INTEGER, STRING
>#DEFINE WM_USER	                0x400
>#DEFINE EM_SETCHARFORMAT       (WM_USER + 68)
>#DEFINE CFE_PROTECTED           0x00000010
>#DEFINE CFM_BACKCOLOR           0x04000000
>#DEFINE CFM_PROTECTED           0x00000016
>#DEFINE SCF_SELECTION           0x00000001
>WITH this.Parent
>  IF .RTFTextObj.SelLength > 0
>    loCharFormat = GetCharFormatStruct()
>    loCharFormat.crBackColor = .Highlight.Fillcolor
>    loCharFormat.dwMask      = BITOR(CFM_PROTECTED,CFM_BACKCOLOR)
>    loCharFormat.dwEffects   = CFE_PROTECTED
>    lcCharFormat = loCharFormat.GetString()
>    IF !EMPTY(lcCharFormat)
>      IF SendMessage(.RTFTextObj.hWnd, EM_SETCHARFORMAT, BITOR(SCF_SELECTION,SCF_WORD), @lcCharFormat) = 0
>        WAIT WINDOW "Set Background Color Failed" NOWAIT
>      ENDIF
>    ENDIF
>    RELEASE loCharFormat
>  ENDIF
>ENDWITH
>
>
>I am using the STRUCT.VCX class by Christof Lange and Mark Wilden; the call to the GetCharFormatStruct procedure is as follows:
>
>
>************************************************************************************************
>*
>*  Procedure for setting the character font format of the selected text in a RichEdit control
>*  (uses the STRUCT.VCX class developed by Christof Lange and Mark Wilden)
>*
>FUNCTION GetCharFormatStruct
>  LOCAL loCharFormat
>  loCharFormat = CREATEOBJECT("CharFormat2")
>  RETURN loCharFormat
>ENDFUNC
>
>
>DEFINE CLASS CharFormat2 AS Struct OF "struct.vcx"
>  cbSize          = 0
>  dwMask          = 0
>  dwEffects       = 0
>  yHeight         = 0
>  yOffset         = 0
>  crTextColor     = 0
>  bCharSet        = 0
>  bPitchAndFamily = 0
>  szFaceName      = ""
>  wWeight         = 0
>  sSpacing        = 0
>  crBackColor     = 0
>  lcid            = 0
>  dwReserved      = 0
>  sStyle          = 0
>  wKerning        = 0
>  bUnderlineType  = 0
>  bAnimation      = 0
>  bRevAuthor      = 0
>  bReserved1      = 0
>
>  PROCEDURE init
>    DODEFAULT()
>    this.cbsize = this.sizeof()
>  ENDPROC
>
>  PROCEDURE GetCMembers
>    RETURN 	"UINT     ul:cbSize,"         + ;
>		"DWORD    ul:dwMask,"         + ;
>		"DWORD    ul:dwEffects,"      + ;
>		"LONG     l:yHeight,"         + ;
>		"LONG     l:yOffset,"         + ;
>		"COLORREF ul:crTextColor,"    + ;
>		"BYTE     b:bCharSet,"        + ;
>		"BYTE     b:bPitchAndFamily," + ;
>		"TCHAR    0c32:szFaceName,"   + ;
>		"WORD     uw:wWeight,"        + ;
>		"SHORT    w:sSpacing,"        + ;
>		"COLORREF ul:crBackColor,"    + ;
>		"LCID     ul:lcid,"           + ;
>		"DWORD    ul:dwReserved,"     + ;
>		"SHORT    w:sStyle,"          + ;
>		"WORD     uw:wKerning,"       + ;
>		"BYTE     b:bUnderlineType,"  + ;
>		"BYTE     b:bAnimation,"      + ;
>		"BYTE     b:bRevAuthor,"      + ;
>		"BYTE     b:bReserved1"
>  ENDPROC
>ENDDEFINE
>
>
>I cannot get the text to highlight with the color set by the .Highlight.Fillcolor property value (set to yellow or red for testing). Any help would be appreciated in what is wrong above. Thanks.


Hi Greg,

First of all, you have the wrong structure. Here is the correct one:
  cbSize          = 0
  dwMask          = 0
  dwEffects       = 0
  yHeight         = 0
  yOffset         = 0
  crTextColor     = 0
  bCharSet        = 0
  bPitchAndFamily = 0
  szFaceName      = ""
******
*** CHARFORMAT structure word alignment
  wPad            = 0
******
  wWeight         = 0
  sSpacing        = 0
  crBackColor     = 0
  lcid            = 0
  dwReserved      = 0
  sStyle          = 0
  wKerning        = 0
  bUnderlineType  = 0
  bAnimation      = 0
  bRevAuthor      = 0
  bReserved1      = 0
Now, there are other things that involved RichEdit control. So, I have a few question first:

1. What is the your OS?

2. What is the RichText Control Version? Is it "Version 6.0 (SP4)" or "Version 6.0 (SP6)" ?

3. When you modify the form (the one with the RTF), call GetModuleHandle() API from the command window:
? GetModuleHandle( 'RichEd20.dll' )
What is the value, other than 0?
Herman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform