I've been developing a tool with BlueGUI and created some functions that I've been using to make handling the handles etc easier.
First of I create a custom variable type to hold my gadget handle information:
` Setup gadget vars
type gadget
handle AS INTEGER
description AS STRING
endtype
GLOBAL DIM gadgetList(200) AS gadget
GLOBAL nextGadget AS INTEGER
nextGadget=1
The next bit is a way of displaying an event code:
function eventTypeToString(eventNumber AS INTEGER)
LOCAL eventString AS STRING
eventString="Unknown Event "+STR$(eventNumer)
if eventNumber=0x202
eventString="Left Mouse Click / Left mouse button Up"
endif
if eventNumber=0x205
eventString="Right Mouse Click / Right mouse button Up"
endif
if eventNumber=0x200
eventString="Mouse Move"
endif
if eventNumber=0x113
eventString="Gadget Timer"
endif
if eventNumber=0x111
eventString="Menu / Toolbar click"
endif
if eventNumber=0x312
eventString="Hot Key"
endif
if eventNumber=513
eventString="Left Button Down"
endif
if eventNumber=0x100
eventString="Key Down"
endif
if eventNumber=0x101
eventString="Key Up"
endif
if eventNumber=0x111
eventString="Combo/Treeview Change"
endif
if eventNumber=0x8
eventString="Lose Focus"
endif
if eventNumber=0x214
eventString="Gadget Sizing"
endif
if eventNumber=0x5
eventString="Gadget Size"
endif
if eventNumber=0x10
eventString="Window Close"
endif
if eventNumber=0xA1
eventString="Window Move"
endif
if eventNumber=0xE0
eventString="Scroll bar change"
endif
endfunction eventString
I did use a select/case statement but during testing I got a crash to desktop and wasnt sure if that was the cause. The if/endif seems to work ok though.
Next is rhe routine I use to add the handles into the array created above:
function addGadget(handle AS INTEGER, description AS STRING)
gadgetList(nextGadget).handle=handle
gadgetList(nextGadget).description=description
nextGadget=nextGadget+1
endfunction
Below is an example of adding some gadgets using this method:
` Value
y=20
handle=createLabel(10, y, 118, 20, "Value", 0)
addGadget(handle,"lblValue")
handle=createEdit (100, y, 100, 20, 0, 0)
addGadget(handle,"txtValue")
Once you have built your interface, you may be thinking, how do I work out what handles are returned by the different events. Well this is done by the next routine.
function GetGadgetString(handle AS INTEGER)
LOCAL sourceString AS STRING
LOCAL lp AS INTEGER
sourceString=""
for lp=1 TO nextGadget-1
if handle=gadgetList(lp).handle
sourceString=gadgetList(lp).description
EXIT
endif
next lp
endfunction sourceString
You pass this function the handle from the event and it will return the text string you gave when you created the gadget:
#CONSTANT WINDOW_CLOSE 0x10
evntSource=eventSource()
evntGadget=GetGadgetString(evntSource)
evntType=eventType()
if evntGadget="winMain"
if evntType=WINDOW_CLOSE
END
endif
endif
Next you may be wondering, How do I update a gadget with text etc. The following function does this for you:
function GetGadgetHandle(gadget AS STRING)
LOCAL handle AS INTEGER
LOCAL lp AS INTEGER
handle=0
for lp=1 TO nextGadget-1
if gadget=gadgetList(lp).description
handle=gadgetList(lp).handle
EXIT
endif
next lp
endfunction handle
You pass in the gadget name you picked for this gadget and it will return the handle for that gadget. An example of this is:
setGadgetText GetGadgetHandle("txtValue"),"My Text"
They seem to work really quickly, and if you have created a status bar, you can update this with the text values of the events etc. An example of which is here:
evntGadget=GetGadgetString(evntSource)
if evntGadget<>""
setStatusText statusBar,0, "SouceGadget=["+evntGadget+"], EventType=["+eventTypeToString(evntType)+"], EventData=["+STR$(evntData)+"]"
endif
This is great for debugging, An example of using these routines is shown below:
As you can see in the status bar is the events that are happening.
Hope this helps some people.
Jas
----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"