Jump to content

How can a guictrlsetonevent function stop working sometimes??


zaetep
 Share

Recommended Posts

Hi, I'm totally stumped by this one. I have a general purpose input function that allows a user to select one of a group of radio buttons. As soon as a radio is clicked the gui deletes and returns the text of the choice to the calling function.

It works really nicely but i have two functions that call it and the event function for selecting a button never runs, it just gets stuck in the loop waiting for a response.

It still works in all other cases (in the same execution of the program). And cutting and pasting (to check for typos etc) the call and the function to a test file (not connected to the rest of the code) it works.

Is there anything that can stop an event function being called?

the function is:

~ ;takes possible choices separated by | in a string, returns the chosen answer or "input cancelled" if closed

Func RadioQBox($title, $prompt, $choices)

Local $c = StringSplit($choices, "|");make array into string

Local $rads[$c[0] + 1] = [$c[0]];array for control ids

Local $ypos = 50, $msg, $sel;set y postion

Local $hgt = ($c[0] * 40) + 100;set height

GUISetState(@SW_DISABLE, $siteGui);disable main gui

Local $radGui = GUICreate($title, 500, $hgt, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST);build form

GUICtrlCreateGroup($prompt, 50, 10, 400, $hgt - 10)

For $i = 1 To $c[0];create radios

$rads[$i] = GUICtrlCreateRadio($c[$i], 60, $ypos, 380, 15)

GUICtrlSetOnEvent($rads[$i], "RadioChoice");set on event function

$ypos = $ypos + 40

Next

GUISetState(@SW_SHOW)

Global $RadChoice = 0;selected flag

While Not $RadChoice

Sleep(200)

;db("rboxloop")

WEnd

;db("Radiochoice answer")

For $i = 1 To $c[0]

If $RadChoice = $rads[$i] Then

$sel = $c[$i]

$RadChoice = 0

GUIDelete($radGui)

If $sel = 'other' Then

db("Radiochoice other")

$sel = InputBox($title, $prompt & @CRLF & "It is recommended that you make your answer roughly the same length and format as the other options")

EndIf

EndIf

Next

GUISetState(@SW_ENABLE, $siteGui)

Return $sel

EndFunc ;==>RadioQBox

The event is

Func RadioChoice()

$RadChoice = @GUI_CtrlId

;db("radiochoice event", @GUI_CtrlId, @GUI_WinHandle, @GUI_CtrlHandle)

EndFunc ;==>RadioChoice

Hope you can help

Edited by zaetep
Link to comment
Share on other sites

Sorry about the format in the previous post :oops:

Ok i think i have found the problem. Apparently the event function has to complete before another event can be registered.

I can fix this by having the event just set flags that are picked up in the main loop but it is making things a bit slow.

Is there a way to clear the event so another one can take place before the function ends?

Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

  • Moderators

zaetep,

The Interrupting a running function tutorial in the Wiki should help you. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...