Here my code:
Code: Select all
#include <fivewin.ch>
function Main()
local oWnd, oCombo, aItems, cCurr
DEFINE WINDOW oWnd from 100,100 to 200,400 PIXEL
aItems := GETFONTNAMES(oWnd:getDc())
oWnd:ReleaseDC()
//@ 10,10 COMBOBOX oCombo VAR cCurr ITEMS aItems SIZE 200,25 PIXEL STYLE CBS_DROPDOWNLIST+CBS_OWNERDRAWFIXED
// precompile the code upper to get the code below
oCombo := MyCombo():New( 10, 10, { | u | If( PCount()==0, cCurr, cCurr:= u ) }, aItems, ;
200, 25,,,,,,, .T.,,, .F.,, .F.,{""},,CBS_DROPDOWNLIST+CBS_OWNERDRAWFIXED,,, "oCombo",,,,,,, )
oCombo:lOwnerDraw := .T.
ACTIVATE WINDOW oWnd
return 0
class MyCombo inherit TComboBox
METHOD DrawItem( nIdCtl, nPStruct )
endclass
#define WHITE_BRUSH 0
METHOD DrawItem( nIdCtl, nPStruct ) CLASS MyCombo
LOCAL aData := GetDrawItemStruct(nPStruct)
LOCAL hDC := aData[7], aRect := {aData[8],aData[9],aData[10],aData[11]}
LOCAL cFont, oFont
if aData[3]>=0
cFont := ::aItems[aData[3]+1]
endif
FillRect(hDC,aRect, GetStockObject( WHITE_BRUSH ) )
if aData[5]=0
// unselected item
//MoveTo(hDC, aData[9], aData[8])
//LineTo(hDC, aData[11], aData[10])
else
// Selected item
MoveTo(hDC, aData[9], aData[10])
LineTo(hDC, aData[11], aData[8])
endif
if !empty(cFont)
DEFINE Font oFont NAME cFont
oFont:Activate(hDC)
DrawTextEx(hDC,cFont,aRect,1)
oFont:End()
endif
return 1
What do you think?