Silvio.Falconi wrote:I have a combobox
@ 10, 120 COMBOBOX aget[1] VAR cCategoria Items ArrTranspose(aCategorie )[ 2] size 200,90 PIXEL OF oDlg
...
I wish change color and font of text only on these two items
Please test this sample and use your own font and colors for these items
- Code: Select all Expand view RUN
- #include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oCbx, aItems[7], cItem, oFont
DEFINE FONT oFont NAME "VERDANA" SIZE 0,-16
DEFINE WINDOW oWnd
oWnd:SetFont( oFont )
AEval( aItems, { |c,i | aItems[ i ] := NTOCDOW( i ) } )
cItem := aItems[ 1 ]
@ 80,40 COMBOBOX oCbx VAR cItem ITEMS aItems SIZE 150,300 PIXEL OF oWnd ;
OWNERDRAW OwnerDrawItem( Self, nIdCtl, oItemStruct )
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//
function OwnerDrawItem( Self, nIdCtl, oItem )
local oFont, nClrText, nClrBack
local hDC := oItem:hDC
if oItem:itemID >= 0
if oItem:itemID == 0 .or. oItem:itemID == ( Len( ::aItems ) - 1 )
oFont := ::oFont:Bold()
nClrBack := If( lAnd( oItem:itemState, 1 ), CLR_HGREEN, CLR_YELLOW )
nClrText := If( lAnd( oItem:itemState, 1 ), CLR_HRED, CLR_HRED )
else
nClrBack := If( lAnd( oItem:itemState, 1 ), CLR_HGRAY, CLR_WHITE )
nClrText := If( lAnd( oItem:itemState, 1 ), CLR_BLACK, CLR_BLACK )
endif
FW_SayText( hDC, oItem:itemData, oItem:aRect,"L", IfNil( oFont, ::oFont ), ;
nClrText, nARGB( 255, nClrBack ) )
RELEASE FONT oFont
endif
return 1