Hi Stefan,
Thanks for your help.
I tried your code using the sample "testrich.prg" included in FWH\samples directory. However, REGetFormat2() always return the same result
no matter if the selection has font effects (sup/sub) or has no font effects. Could it be that I'm using it incorrectly?
Below is the source code I tested: ( Also, how can I get other font effects like italic, bold, underline? ).
// FWH and FW++ RichEdit sample
include "FiveWin.ch"
include "Constant.ch"
include "WColors.ch"
include "RichEdit.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oRich
local hRichDLL := LoadLibrary( "riched20.dll" )
local lSyntaxHL := .f.
DEFINE DIALOG oDlg NAME "Test"
oRich = TRichEdit():Redefine( 100, { || "" }, oDlg )
oRich:lHighLight = .f.
REDEFINE BUTTON ID 110 ;
ACTION oRich:SetText( MemoRead( "TestRich.prg" ) )
REDEFINE CHECKBOX lSyntaxHL ID 115 OF oDlg ;
ON CHANGE ( oRich:lHighLight := lSyntaxHL,;
oRich:SetText( oRich:GetText() ) )
REDEFINE BUTTON ID 120 ;
ACTION oRich:LoadFromRTFFile( cGetFile( "RTF file (.rtf) | .rtf" ) )
REDEFINE BUTTON ID 130 ;
ACTION oRich:SaveToRTFFile( cGetFile( "RTF file (.rtf) | .rtf",;
"Please write a filename", "test" ) )
REDEFINE BUTTON ID 998 ACTION ( Test( oRich, oDlg ) )
ACTIVATE DIALOG oDlg CENTERED ;
// ON INIT oRich:AutoURLDetect( .t. )
FreeLibrary( hRichDLL )
return nil
//----------------------------------------------------------------------------//
function Test( oRich, oDlg )
LOCAL cStr, aSel := {}, nC
local aFormat
local lSubScript
local lSuperScript
local lCapital
IF oRich:IsSelection()
aFormat := REGetCharFormat2 (oDlg)
lSubScript := aFormat[1] > 0
lSuperScript := aFormat[2] > 0
lCapital := aFormat[3] > 0
xBrowse( aFormat )
ELSE
Msginfo( 'Nothing selected! ')
END
RETURN ( nil )
//----------------------------------------------------------------------------//
pragma BEGINDUMP
include <Windows.h>
include <HbApi.h>
include <Richedit.h>
HB_FUNC ( REGETCHARFORMAT2)
{
CHARFORMAT2 cf;
//DWORD lResult;
cf.cbSize = sizeof (cf);
cf.dwMask = CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_ALLCAPS;
cf.dwEffects = CFE_SUBSCRIPT | CFE_SUPERSCRIPT | CFE_ALLCAPS;
SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, SCF_SELECTION, ( LPARAM ) &cf );
hb_reta (3);
hb_storni (cf.dwEffects & CFE_SUBSCRIPT, -1, 1);
hb_storni (cf.dwEffects & CFE_SUPERSCRIPT, -1, 2);
hb_storni (cf.dwEffects & CFE_ALLCAPS, -1, 3);
}
pragma ENDDUMP
Thanks...
Kind regards,
ryugarai27