It seems that the dark mode of the combobox can be set as the code below on Windows 10+.
Code: Select all
UsePNGImageDecoder()
#BackColor = $999999
Global hBrushBackground = CreateSolidBrush_(#BackColor)
#APP_OldWndProc = "MyApp_OldWndProc"
Procedure WndProc_MainWindow(hWnd, uMsg, wParam, lParam)
Protected Result = #PB_ProcessPureBasicEvents
Protected hParent, buffer.s
Select uMsg
Case #WM_CTLCOLOREDIT
buffer = Space(64)
hParent = GetParent_(lParam)
If GetClassName_(hParent, @buffer, 64)
If buffer = "ComboBox"
;SetBkMode_(wParam, #TRANSPARENT)
SetBkColor_(wParam, #BackColor)
SetTextColor_(wParam, #White)
ProcedureReturn hBrushBackground
EndIf
EndIf
Case #WM_CTLCOLORLISTBOX
buffer = Space(64)
If GetClassName_(lParam, @buffer, 64)
If buffer = "ComboLBox"
SetTextColor_(wParam, #White)
ProcedureReturn hBrushBackground
EndIf
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
Procedure WndProc_ComboboxChild(hWnd, uMsg, wParam, lParam)
Protected old = GetProp_(hWnd, #APP_OldWndProc)
Protected hParent, buffer.s
Select uMsg
Case #WM_ERASEBKGND
;GetClientRect_(hWnd, rt.RECT)
;FillRect_(wParam, rt, hBrushBackground)
;ProcedureReturn 1
Case #WM_CTLCOLOREDIT
buffer = Space(64)
hParent = GetParent_(lParam)
If GetClassName_(hParent, @buffer, 64)
If buffer = "ComboBox"
Debug "WM_CTLCOLOREDIT"
;SetBkMode_(wParam, #TRANSPARENT)
SetBkColor_(wParam, #BackColor)
SetTextColor_(wParam, #White)
ProcedureReturn hBrushBackground
EndIf
EndIf
Case #WM_CTLCOLORLISTBOX
buffer = Space(64)
If GetClassName_(lParam, @buffer, 64)
If buffer = "ComboLBox"
Debug "WM_CTLCOLORLISTBOX"
SetBkColor_(wParam, #BackColor)
SetBkMode_(wParam, #TRANSPARENT)
SetTextColor_(wParam, #White)
ProcedureReturn hBrushBackground
EndIf
EndIf
Case #WM_NCDESTROY
RemoveProp_(hWnd, #APP_OldWndProc)
EndSelect
ProcedureReturn CallWindowProc_(old, hWnd, uMsg, wParam, lParam)
EndProcedure
LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/world.png")
If OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0, #Gray)
SetWindowCallback(@WndProc_MainWindow())
ComboBoxGadget(0, 10, 10, 250, 25, #PB_ComboBox_Editable)
For a = 1 To 10
AddGadgetItem(0, -1, "ComboBox editable... " + Str(a))
Next
SetGadgetState(0, 0)
ComboBoxGadget(1, 10, 40, 250, 25)
For a = 1 To 10
AddGadgetItem(1, -1,"ComboBox item " + Str(a))
Next
SetGadgetState(1, 0)
ComboBoxGadget(2, 10, 70, 250, 25, #PB_ComboBox_Image)
For a = 1 To 10
AddGadgetItem(2, -1, "ComboBox item with image " + Str(a), ImageID(0))
Next
SetGadgetState(2, 0)
ComboBoxGadget(3, 10, 100, 250, 25, #PB_ComboBox_Image | #PB_ComboBox_Editable)
For a = 1 To 10
AddGadgetItem(3, -1, "Editable ComboBox item with image " + Str(a), ImageID(0))
Next
SetGadgetState(3, 0)
If OSVersion() >= #PB_OS_Windows_10
SetWindowTheme_(GadgetID(0), "DarkMode_CFD", "Combobox")
SetWindowTheme_(GadgetID(1), "DarkMode_CFD", "Combobox")
hChild = GetWindow_(GadgetID(2), #GW_CHILD)
If hChild
SetWindowTheme_(hChild, "DarkMode_CFD", "Combobox")
old = SetWindowLongPtr_(hChild, #GWLP_WNDPROC, @WndProc_ComboboxChild())
SetProp_(hChild, #APP_OldWndProc, old)
EndIf
hChild = GetWindow_(GadgetID(3), #GW_CHILD)
If hChild
SetWindowTheme_(hChild, "DarkMode_CFD", "Combobox")
old = SetWindowLongPtr_(hChild, #GWLP_WNDPROC, @WndProc_ComboboxChild())
SetProp_(hChild, #APP_OldWndProc, old)
EndIf
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
DeleteObject_(hBrushBackground)