@plouf :
Would be possible then to add the possibility to have
a SetGadgetCallBack() so it can catch repaint messages ?
As a gadget is considered as a window under MS-Windows you can do a SetWindowCallback() on a gadget, and thus intercept any gadget events (#WM_PAINT for example) in this callback independtly of your main window events loop.
I have done such an example :
Code: Select all
Structure SKIN
fg.l
bg.l
mode.l
brush.l
old.l
EndStructure
;----------------------------------------------------------
Procedure ComboCallBack( hWnd.l, Msg.l, wParam.l, lParam.l )
*skin.SKIN = GetWindowLong_( hWnd, #GWL_USERDATA )
Result.l = CallWindowProc_( *skin\old, hWnd, Msg, wParam, lParam )
If (Msg=#WM_DESTROY)
DeleteObject_( *skin\brush )
GlobalFree_( *skin )
PostQuitMessage_(0)
ElseIf (Msg=#WM_CTLCOLOREDIT) Or (Msg=#WM_CTLCOLORLISTBOX)
SetTextColor_( wParam, *skin\fg )
SetBkColor_ ( wParam, *skin\bg )
SetBkMode_ ( wParam, *skin\mode )
Result = *skin\brush
EndIf
ProcedureReturn Result
EndProcedure
;----------------------------------------------------------
Procedure.l CustomCombo( id.l, fgColor.l, bgColor.l, brColor.l, mode.l )
skinStruct.l = GlobalAlloc_(0,SizeOf(SKIN))
If skinStruct <> #NULL
*skin.SKIN = skinStruct
*skin\fg = fgColor
*skin\bg = bgColor
*skin\mode = mode
*skin\brush = CreateSolidBrush_( brColor )
*skin\old = SetWindowLong_( GadgetID(id), #GWL_WNDPROC, @ComboCallBack() )
SetWindowLong_( GadgetID(id), #GWL_USERDATA, *skin )
EndIf
EndProcedure
;----------------------------------------------------------
OpenWindow( 0, 200,400,200,100, #PB_Window_SystemMenu, "Colorisation et Callback" )
CreateGadgetList( WindowID() )
ComboBoxGadget( 0, 10, 10, 180, 120, #PB_ComboBox_Editable )
ComboBoxGadget( 1, 10, 40, 180, 120, #PB_ComboBox_Editable )
ComboBoxGadget( 2, 10, 70, 180, 120, #PB_ComboBox_Editable )
For i=0 To 2
AddGadgetItem( i, -1, "une ligne d'exemple" )
AddGadgetItem( i, -1, "et encore une autre" )
AddGadgetItem( i, -1, "une p'tite dernière" )
AddGadgetItem( i, -1, "pour finir..." )
SetGadgetState( i, i )
Next
CustomCombo( 0, $00FFFF, $888888, $000000, #OPAQUE )
CustomCombo( 1, $BBFFFF, $AAFFAA, $FFCCCC, #OPAQUE )
CustomCombo( 2, $AA0000, $888888, $DDFFFF, #TRANSPARENT )
Repeat : Until WaitWindowEvent() = #PB_EventCloseWindow
End
Note this line, very important :
Code: Select all
*skin\old = SetWindowLong_( GadgetID(id), #GWL_WNDPROC, @ComboCallBack() )
which allow you to overlap the current API callback...