In der Microsoft Platform SDK steht, dass Windows XP auch Buttons bei CustomDraw unterstützt.
Geht das auch mit PureBasic?
CUSTOMDRAW für Buttons
Ja , du musst nur als Flag #BS_OWNERDRAW angeben und dann
selber malen.
Beispiel : (uralt
)
selber malen.
Beispiel : (uralt

Code: Alles auswählen
Procedure WindowCallback(hWnd,msg,wParam,lParam)
Protected old.l
Protected *item.DRAWITEMSTRUCT
Protected point.POINT , oldpoint.POINT
old = GetProp_(hWnd,"PROP_OLDPROC")
Select msg
Case #WM_DRAWITEM
*item = lParam
DC = *item\hdc
w = *item\rcItem\right - *item\rcItem\left
h = *item\rcItem\bottom - *item\rcItem\top
MapWindowPoints_(GetParent_(hWnd),hWnd,@point,1)
BackBrush = GetClassLong_(hWnd, #GCL_HBRBACKGROUND)
SetBrushOrgEx_(DC,point\x,point\y,@oldpoint)
FillRect_(DC,*item\rcItem,BackBrush)
SetBrushOrgEx_(DC,oldpoint\x,oldpoint\y,0)
If *item\itemState & #ODS_SELECTED
hpen = CreatePen_(#PS_SOLID,1,$849584)
hbrush = CreateSolidBrush_($BCC5BC)
*item\rcItem\bottom + 2
Else
hbrush = CreateSolidBrush_($BCC5BC)
EndIf
If *item\itemState & #ODS_DISABLED
SetTextColor_(DC,$666666)
hpen = CreatePen_(#PS_SOLID,1,$849584)
EndIf
SelectObject_(DC,hpen)
SelectObject_(DC,hbrush)
Ellipse_(DC,0,0,w,h)
DeleteObject_(hpen)
DeleteObject_(hbrush)
SetBkMode_(DC,#TRANSPARENT)
DrawText_(DC, GetGadgetText(*item\CtlID), Len(GetGadgetText(*item\CtlID)), *item\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
ProcedureReturn #True
Case #WM_DESTROY
RemoveProp_(hWnd,"PROP_OLDPROC")
EndSelect
ProcedureReturn CallWindowProc_(old,hWnd,msg,wParam,lParam)
EndProcedure
Procedure RoundButton(id,x,y,cx,cy,text.s,flags=0)
Protected temp.l
Static old.l
temp = ButtonGadget(id,x,y,cx,cy,text,flags|#BS_OWNERDRAW)
If id = #PB_Any
hWnd = GadgetID(temp)
Else
hWnd = temp
EndIf
If old = 0
old = SetWindowLong_(GetParent_(hWnd),#GWL_WNDPROC,@WindowCallback())
SetProp_(GetParent_(hWnd),"PROP_OLDPROC",old)
EndIf
ProcedureReturn temp
EndProcedure
*win.LONG = OpenWindow(#PB_Any,0,0,200,200,"",$C80001)
CreateGadgetList(*win\l)
rb0 = RoundButton(#PB_Any,10,10,50,50,"blub") ;: DisableGadget(rb0,1)
rb1 = RoundButton(#PB_Any,60,60,50,50,"blub")
rb2 = RoundButton(#PB_Any,10,90,50,50,"blub")
Repeat
e = WaitWindowEvent()
If e = #PB_Event_Gadget
Select EventGadget()
Case rb0 : Debug "Press rb0"
Case rb1 : Debug "Press rb1"
Case rb2 : Debug "Press rb2"
EndSelect
ElseIf e = #PB_Event_CloseWindow
Break
EndIf
ForEver
End
Dann hab ich es falsch verstanden, aber versuch mal das :
Code: Alles auswählen
Procedure _subclass_cb_(hWnd,uMsg,wParam,lParam)
Protected *cdntfy.NMCUSTOMDRAW
If #WM_NOTIFY = uMsg
*cdntfy = lParam
If *cdntfy\hdr\code = #NM_CUSTOMDRAW
If *cdntfy\dwDrawStage = #CDDS_PREPAINT
If *cdntfy\uItemState & #CDIS_HOT = #CDIS_HOT
brush = CreateSolidBrush_($00FFFF)
Else
brush = CreateSolidBrush_($808000)
EndIf
FillRect_(*cdntfy\HDC,*cdntfy\rc,brush)
DeleteObject_(brush)
ProcedureReturn #CDRF_DODEFAULT
EndIf
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
hWnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,200,200,"leer")
SetWindowCallback(@_subclass_cb_())
CreateGadgetList(hWnd)
ButtonGadget(0,10,10,100,100,"sdfsdf")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow