I will eventually get out a class covering the use of these more obscure control types. <sorry for the delay> Chip
_____ From: David [mailto:eleph...@tele2.no] Sent: Monday, April 02, 2012 8:14 AM To: gw-scripting@gwmicro.com Subject: Retrieving a value from a dialog - Need a hand, pleas. Hmm, have started learning how to create a dialog, based on an XML file. I now have been able to make my dialog show up, when a hotkey is pressed. But I seem to have a problem in retrieving some returns from the dialog. OK, I have created a dialog named SETTINGS . This dialog holds a group with the ID SoundClipSettings . And, this group, holds a control named VolumeTrackbar . I then used the examples for Class 14, from Chip Orange's scripting course; and created the following Sub and Function. It seems to me, that the dialog works well enough. But exactly how can I retrieve the value from the VolumeTrackbar control. I tried with a line in my function, saying: VTB = VolumeTrackbar ; where VTB is a global variable of my app. If anyone please could give me the exact syntax for this very line, I would be greatly helped. Did find little help in the app developers reference, on this particular problem. It only showed me how to create a Trackbar, not anything as to how to retrieve it. (Sigh!) --- snip of my code --- ' somewhere else in my app, I have the line: Queue "DisplayMyDialog" Sub displayMyDialog() If MyDialog Is Nothing Then Set MyDialog = Dialog(myXMLFile, "SETTINGS", "DialogEventHandler") Else MyDialog.window.Activate End If End Sub Function DialogEventHandler(dObj, dEvent, dId, dControl) ' return "true" if your code handled the event, and false if it did not DialogEventHandler = False ' test on the name of the control involved in this event by examining the "dId" parameter Select Case dId Case "VolumeTrackbar" ' now see what was done with this control by examining the "dEvent" parameter If dEvent = buttonClicked Then ' it's now often the time to do something because this control was clicked ' your code to do something goes here ... ' *** Well, here comes the troublesome line, that gives me headache: *** VTB = VolumeTrackbar DialogEventHandler = True Exit Function End If ' now create a "Case" similar to the above for each control in your dialog, and keep adding them somewhere before the "Case Else" line Case "ButtonOk" ' now see what was done with this control by examining the "dEvent" parameter If dEvent = buttonClicked Then Speak "Volume has been set to " &VTB &" percent." ' it's now often the time to save options because this control was clicked ' and so your code to do this goes here, using a "queue" command ' queue "saveOptions" ' now cause the dialog to start closing dObj.close DialogEventHandler = True Exit Function End If ' note that the case for your "cancel" button is often identical to that of the "ok" button, except for saving options Case "ButtonCancel" ' now see what was done with this control by examining the "dEvent" parameter If dEvent = buttonClicked Then ' now cause the dialog to start closing dObj.close DialogEventHandler = True Exit Function End If Case Else ' no control ID was recognized ' in this portion we test on events not related to a specific control If dEvent = dialogCreated Then ' this event happens before all others, and is the dialog being created ' now initialize your various controls in the dialog DialogEventHandler = True Exit Function ElseIf dEvent = dialogClosing Then ' something caused this dialog to close, and now it's closing, set your global variable for this dialog or whatever else you need to do DialogEventHandler = True Exit Function End If End Select End Function