Posted: Mon Nov 07, 2005 12:13 pm
The following will colour the edit field and drop down list of an editable combo. If you switch to an uneditable combo, then the following still works on the drop down part, but not the static field. For that you will need Sparkie's code above.
Hope it helps.
Code: Select all
Global oldcombproc, BackBrush
BackBrush = CreateSolidBrush_(#blue)
Procedure ComboCallBack( hWnd.l, Message.l, wParam.l, lParam.l )
If (Message = #WM_CTLCOLOREDIT) Or (Message = #WM_CTLCOLORLISTBOX)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam,#red)
SetBkColor_(wParam,#blue)
Result = BackBrush
Else
Result.l = CallWindowProc_(oldcombproc, hWnd, Message, wParam, lParam )
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow( 0, 200,400,200,100, #PB_Window_SystemMenu, "Colorisation et Callback" )
CreateGadgetList( WindowID() )
ComboBoxGadget( 1, 10, 10, 180, 120, #PB_ComboBox_Editable )
AddGadgetItem(1, -1, "123" )
AddGadgetItem(1, -1, "456" )
AddGadgetItem(1, -1, "789" )
setgadgetstate(1,0)
oldcombproc = SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @ComboCallBack())
Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
End