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.
RichtText Class
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: RichtText Class
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
EMG
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
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.
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.