Unicode + RichEdit

Unicode + RichEdit

Postby ryugarai27 » Fri Jul 09, 2010 9:16 am

Hi FWH Experts,

I'm trying to retrieve the Unicode's hexadecimal value of a selected character in TRichedit object, such as:

greek small letter alpha := α
greek small letter beta := β
...
...

I tried Str2Hex(AnsiToWide( oRich:GetSel() )) but FWH raises an error "hb_xgrab can't allocate memory" and terminates the application.

Is there a function in FWH to rerieve the Unicode's hexadecimal value of a selected character?

Below is the code and .rc file I used for testing...Thanks.

//----------- CODE -------------------------------------------------------------
// FWH and FW++ RichEdit sample

#include "FiveWin.ch"
#include "Constant.ch"
#include "WColors.ch"
#include "RichEdit.ch"

STATIC oMsg, oLen, oRow, oCol

//----------------------------------------------------------------------------//

function Main()

local oDlg, oRich
local hRichDLL := LoadLibrary( "riched20.dll" )
local lSyntaxHL := .f.
local aF, aF2

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 )

IF oRich:IsSelection()
Msginfo( Str2Hex(AnsiToWide( oRich:GetSel() ) ))
ELSE
Msginfo( 'Nothing selected! ')
END

RETURN ( nil )


//------------- .RC file -----------------------
#include "..\..\include\winapi.ch"

#define IDC_EDIT1 101
Test DIALOG 41, 64, 409, 229
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
CHECKBOX "Activate syntax highlight", 115, 65, 182, 92, 11, BS_AUTOCHECKBOX | WS_TABSTOP
PUSHBUTTON "L&oad RTF file", 120, 162, 179, 50, 16
PUSHBUTTON "&Save RTF file", 130, 226, 179, 50, 16
PUSHBUTTON "&End", IDCANCEL, 290, 179, 50, 16
PUSHBUTTON "&Test", 998, 354, 179, 50, 16
}


Kind regards,
ryugarai27
User avatar
ryugarai27
 
Posts: 65
Joined: Fri Feb 13, 2009 12:03 pm
Location: Manila, Philippines

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests