I have been trying to find a solution to the problem of a readonly Combobox Gadget, I have searched the forum but have not been able to find a suitable solution, the only one that looked good was to grey - disable some of the items, but for the life of me every time I tranfered the code into my application it did not work, something to do with the callback?
Anyway I found a solution that seems to work but I am not should if it is really the right way to go.
Code: Select all
Enumeration
#Window1
#WhoText
#Who
#Review
#Restore
#Quit
EndEnumeration
Global Off.i
Dim Officer.s(80)
Details.s = "List Officer.txt"
If ReadFile(0,Details.s)
Off.i = 0
While Eof(0) = 0
Off = Off + 1
Officer.s(Off) = ReadString(0)
Wend
CloseFile(0)
Else
MessageRequester("Information","Couldn't open the" + Chr(10) + Chr(10) + Details.s + Chr(10) + Chr(10) + " Please check network connection.",0|#MB_ICONWARNING)
EndIf
OpenWindow(#Window1, 0, 0,300,170,"Combo Box Readonly",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
TextGadget (#WhoText, 25, 20,110, 20," Who is responsible",#PB_Text_Border)
ComboBoxGadget (#Who, 125, 20,140, 20)
ButtonGadget (#Review, 100, 60,105, 20," Review")
ButtonGadget (#Restore,100, 90,105, 20," Restore")
ButtonGadget (#Quit, 100,120,105, 20," Quit")
For a = 1 To Off.i
AddGadgetItem(#Who,-1,Officer.s(a))
Next a
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
Case #Review
Gosub ReadOnly
Case #Restore
Gosub RestoreList
Case #Quit
End
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
End
Readonly:
Result = GetGadgetState(#Who)
Result$ = GetGadgetItemText(#Who,Result)
ClearGadgetItems(#Who)
AddGadgetItem(#Who,-1,Result$)
SetGadgetText(#Who,Result$)
Return
RestoreList:
ClearGadgetItems(#Who)
For a = 1 To Off.i
AddGadgetItem(#Who, -1,Officer.s(a))
Next a
Return
Thanks
Leo


