Reduce the size of several Gadgets
Posted: Mon Jun 06, 2011 9:54 pm
Have you ever had the problem that not all Gadgets fit into a window
or the window looks too crowded? Apple's ControlManager API lets
you reduce the size of several Gadgets with a function which I have
put into a simple procedure to be called with the number of the Gadget
you want to be reduced in size:
or the window looks too crowded? Apple's ControlManager API lets
you reduce the size of several Gadgets with a function which I have
put into a simple procedure to be called with the number of the Gadget
you want to be reduced in size:
Code: Select all
ImportC ""
HideControl(ControlRef.L)
SetControlData(ControlRef.L, ControlPartCode.L, TagName.L, BufferSize.L, *Buffer)
ShowControl(ControlRef.L)
EndImport
#kControlEntireControl = 0
#kControlSizeSmall = 1
#kControlSizeTag = 'size'
Procedure ReduceGadgetSize(GadgetID.L)
Protected ControlSize.W
HideControl(GadgetID(GadgetID))
ControlSize = #kControlSizeSmall
SetControlData(GadgetID(GadgetID), #kControlEntireControl, #kControlSizeTag, SizeOf(ControlSize), @ControlSize)
ShowControl(GadgetID(GadgetID))
EndProcedure
OpenWindow(0, 200, 100, 400, 195, "Normal and small Gadgets")
CheckBoxGadget(0, 10, 10, 180, 20, "Normal CheckBoxGadget")
CheckBoxGadget(1, 210, 10, 180, 20, "Small CheckBoxGadget")
ReduceGadgetSize(1)
OptionGadget(2, 10, 40, 180, 20, "Normal OptionGadget")
OptionGadget(3, 210, 40, 180, 20, "Small OptionGadget")
ReduceGadgetSize(3)
ButtonGadget(4, 10, 70, 180, 20, "Normal ButtonGadget")
ButtonGadget(5, 210, 70, 180, 20, "Small ButtonGadget")
ReduceGadgetSize(5)
TrackBarGadget(6, 10, 100, 180, 20, 0, 20)
TrackBarGadget(7, 210, 102, 180, 20, 0, 20)
ReduceGadgetSize(7)
ScrollBarGadget(8, 10, 130, 180, 20, 0, 20, 1, #PB_ScrollBar_Vertical)
ScrollBarGadget(9, 210, 132, 180, 20, 0, 20, 1, #PB_ScrollBar_Vertical)
ReduceGadgetSize(9)
ComboBoxGadget(10, 10, 160, 180, 20)
AddGadgetItem(10, 0, "Normal ComboBox")
SetGadgetState(10, 0)
ComboBoxGadget(11, 210, 162, 180, 20)
AddGadgetItem(11, 0, "Small ComboBox")
SetGadgetState(11, 0)
ReduceGadgetSize(11)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow