ComboBox_Sum
Posted: Mon Feb 26, 2007 2:00 pm
A very simple method for progressively adding comboBoxes together for various option combinations which I can't recall having seen used in this forum anywhere.
fwiw: It is based on communication PCB dipswitch address setting.
Some of you might find it quite handy.
Regards,
Baldrick
fwiw: It is based on communication PCB dipswitch address setting.
Some of you might find it quite handy.
Code: Select all
Enumeration
#Window_0
#CheckBox_A
#CheckBox_B
#CheckBox_C
#CheckBox_D
#Text_0
#CheckBox_E
#CheckBox_F
#String_0
#Button_0
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 239, 142, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
CheckBoxGadget(#CheckBox_A, 10, 20, 25, 20, "A")
CheckBoxGadget(#CheckBox_B, 55, 20, 30, 20, "B")
CheckBoxGadget(#CheckBox_C, 100, 20, 25, 20, "C")
CheckBoxGadget(#CheckBox_D, 140, 20, 25, 20, "D")
TextGadget(#Text_0, 10, 50, 215, 20, "", #PB_Text_Center | #PB_Text_Border)
CheckBoxGadget(#CheckBox_E, 175, 20, 25, 20, "E")
CheckBoxGadget(#CheckBox_F, 210, 20, 25, 20, "F")
StringGadget(#String_0, 10, 85, 215, 20, "")
ButtonGadget(#Button_0, 95, 110, 50, 25, "Go")
EndIf
EndIf
EndProcedure
Procedure CheckBox_Sum()
If GetGadgetState(#CheckBox_A)
Result+1
EndIf
If GetGadgetState(#CheckBox_B)
Result+2
EndIf
If GetGadgetState(#CheckBox_C)
Result+4
EndIf
If GetGadgetState(#CheckBox_D)
Result+8
EndIf
If GetGadgetState(#CheckBox_E)
Result+16
EndIf
If GetGadgetState(#CheckBox_F)
Result+32
EndIf
ProcedureReturn Result
EndProcedure
Open_Window_0()
Repeat
Ev.l=WaitWindowEvent()
If Ev=#PB_Event_Gadget
Select EventGadget()
Case #CheckBox_A
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #CheckBox_B
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #CheckBox_C
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #CheckBox_D
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #CheckBox_E
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #CheckBox_F
SetGadgetText(#Text_0,Str(CheckBox_Sum()))
Case #Button_0
Opt=CheckBox_Sum()
Select Opt
Case 0 To 23
SetGadgetText(#String_0,"Selection value = "+Str(Opt))
Case 24
SetGadgetText(#String_0,"You have chosen 24")
Case 25 To 63
SetGadgetText(#String_0,"Your choice = "+Str(Opt))
EndSelect
EndSelect
EndIf
If Ev=#PB_Event_CloseWindow
Quit.b=#True
EndIf
Until Quit
Baldrick