Bonus points if you can accept a list index and have the default
selection be wherever in the list it references.
On 11/30/2011 9:14 AM, Aaron Smith wrote:
No need to copy me. I'm right here. I'll add an optional property that
will select the first item automatically.
I'm also not able to duplicate any errors. I just did the following in
Immed:
Set s = SharedObjects("com.gwmicro.gwtoolkit.simpledialogs").listboxdialog
s.additem "red", "red"
s.additem "green", "green"
s.additem "blue", "blue"
s.sort = true
s.defaultbutton = "Select"
s.cancelbutton = "Close"
print s.ChooseItem("Select a color")
Regardless of whether I choose the select button or the close button,
the dialog works as expected.
Aaron
On 11/30/2011 8:52 AM, Chip Orange wrote:
Hi David,
As for no item being selected, I can duplicate this, and don't see
you're doing anything incorrectly; so I'd copy this to Aaron at GW if
I were you.
I cannot duplicate the problem with "cancel" causing an error, and
don't have any thoughts there.
Chip
------------------------------------------------------------------------
*From:* David [mailto:eleph...@tele2.no]
*Sent:* Tuesday, November 29, 2011 10:21 PM
*To:* gw-scripting@gwmicro.com
*Subject:* SimpleDialogs - Wonder what I am doing wrong
I was playing around with a small app, based on one of the samples
found in the GWToolkit documentation. Here is the essential code
snip-it, that causes the problem. The rest of the code, has been
generated by Framework.
Function ChooseFile()
Dim FileList: Set FileList = SO_SimpleDialogs.ListBoxDialog
For Each File In FilesDir.Files
If LCase( File.Name )<> "index.dat" Then FileList.AddItemFile.Name,
File
Next '
FileList.Sort = True
FileList.DefaultButton = "Delete"
FileList.CancelButton = "Close"
ChooseFile = FileList.ChooseItem( "Files found:" )
End Function
MsgBox ChooseFile
I run this on a small folder, and the listbox populates just fine.
The screen shows up, with two buttons at the bottom: Delete, and Close.
First of all, When the listbox opens, I have to press one of my
cursor keys, so as to select the first item on the list. Is there any
way for me to set up the listbox, so that item 1 always will be
selected when the screen opens?
Secondly, if I run the above code, I can select the Delete - or
default - button. The MsgBox will then show me the filename of the
file I chose. And, of course, I want to handle things from there, and
have clear to me what to do.
But if I now choose the Close button - which is defined as the
CancelButton of the listbox - I get the following error thrown at me:
Error Details:
Description: Object variable not set
Line: 392 - ChooseFile = FileList.ChooseItem( "Files found:" )
Why? What is wrong in my code? Far as I can see, I have coded pretty
much what the example in the documentation said. Why then won't the
CancelButton work?
Thirdly, I wanted to set a hotkey for the Delete button. So I changed
the line, to read:
FileList.DefaultButton = "&Amp;Delete"
. Again, I thought I did what the example in the docs tells me to do.
But now, soon as I try to run the app, I get an error thrown at me.
Much fombling proved to me, that if I did the AMP all in lower-case,
the shortcuts work with no error. But if I capitalize any of the A, M
or P, there is the error. Shouldn't the code of the Toolkit be
non-case sensitive? Just wonder, since all other app developing I
have been doing, has been non-sensitive to the casing.
If any of you can tell me why the CancelButton does throw an error on
me, no matter what I try, I will be extremely thankful. And, if you
happen to have an answer for the rest of my trouble, here is the
ears. Smile.
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.