RichtText Class

RichtText Class

Postby reinaldocrespo » Sun Feb 05, 2006 1:49 am

Hi.

I see the function RESetTextColor( ::hWnd, nRGB ) being used to color selected text. I also see :

RESetCharFormat( ::hWnd, ::oFont:cFaceName, ;
::oFont:nHeight * FNT_HEIGHT, nColor, ;
::oFont:nCharSet, ;
::oFont:nPitchFamily, ;
::oFont:nWeight, ;
::oFont:lItalic, ;
::oFont:lUnderline, ;
::oFont:lStrikeOut )

used to set font, size, color, etc... on selected text. They both work just fine to change foreground color of text.

However, I'd like to find a way to change the background color of selected text. Neither of these two seems to do it. Does any body know how can it be done?

thank you,


Reinaldo Crespo-Bazán.
User avatar
reinaldocrespo
 
Posts: 973
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: RichtText Class

Postby Enrico Maria Giordano » Sun Feb 05, 2006 10:38 am

Have a look at EM_SETCHARFORMAT message, SCF_SELECTION option and crBackColor field of CHARFORMAT2 structure (remember to set dwMask field to CFM_BACKCOLOR to activate crBackColor field).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8410
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby reinaldocrespo » Sun Feb 05, 2006 5:36 pm

Enrico;

Thank you for the tip.

I seldom make any contributions.

Below is what I wrote.

That's my 2 cents.

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

HB_FUNC( HIGHLIGHTSELECTION )
{
CHARFORMAT2 cfrm;

memset( ( char * ) &cfrm, 0, sizeof( cfrm ) );

cfrm.cbSize = sizeof( cfrm );
cfrm.dwMask = CFM_BACKCOLOR; //EMG tip. Without it won't work
cfrm.crBackColor = hb_parnl( 2 ); //color passed from xharb source

hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
SCF_WORD | SCF_SELECTION, ( LPARAM ) &cfrm ) );
}

Here is how to call it from xharbour:

HighLightSelection( oRtf:hWnd, nClrBackGround )

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 973
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 144 guests