This is a cross platform solution of the second try for Linux, Mac OS X and WindowsDoubleDutch wrote:It would be good if this was 'built-in' and/or cross platform.
(tested with Windows XP SP2, Windows 7 x86 and Windows 7 x64):




Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC ""
gtk_combo_box_set_button_sensitivity(*GtkComboBox, GtkSensitivityType)
EndImport
Enumeration
#GTK_SENSITIVITY_AUTO
#GTK_SENSITIVITY_ON
#GTK_SENSITIVITY_OFF
EndEnumeration
CompilerEndIf
ComboBoxEnabled.I = #True
If OpenWindow(0, 0, 0, 270, 70, "Enable/Disable ComboBox", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 40, 250, 20, #PB_ComboBox_Editable)
ButtonGadget(1, 60, 10, 140, 20, "Disable ComboBox")
For i = 0 To 15
AddGadgetItem(0, -1, "ComboBox item " + Str(i))
Next i
SetGadgetState(0, 1)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
ComboBoxHandle = GadgetID(0)
ComboBoxEditControlHandle = GetWindow_(ComboBoxHandle, #GW_CHILD)
CompilerEndIf
Repeat
WindowEvent = WaitWindowEvent()
If WindowEvent = #PB_Event_Gadget
If EventGadget() = 1
If ComboBoxEnabled
SetGadgetText(1, "Enable ComboBox")
ComboBoxEnabled = #False
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_combo_box_set_button_sensitivity(GadgetID(0), #GTK_SENSITIVITY_OFF)
CompilerCase #PB_OS_MacOS
DisableGadget(0, #True)
CompilerCase #PB_OS_Windows
DisableGadget(0, #True)
EnableWindow_(ComboBoxEditControlHandle, #True)
CompilerEndSelect
Else
SetGadgetText(1, "Disable ComboBox")
ComboBoxEnabled = #True
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_combo_box_set_button_sensitivity(GadgetID(0), #GTK_SENSITIVITY_ON)
CompilerDefault
DisableGadget(0, #False)
CompilerEndSelect
EndIf
EndIf
EndIf
Until WindowEvent = #PB_Event_CloseWindow
EndIf