Sorry, Bruce, that one got a bit to techie for me. What do you mean by a Listbox event, and how can I then focuse on it? Sorry, but this is first time I am doing listboxes. I thought, since they call it SimpleDialogs, that it would be simple. But start to realize, it is not that simple after all. Specially, when their own sample code throws errors on me. Smile.
Good thing, then we keep GW busy. Smile. ----- Original Message ----- From: BT To: [email protected] Sent: Wednesday, November 30, 2011 5:44 AM Subject: Re: SimpleDialogs - Wonder what I am doing wrong Hi Dave, Yes, I looked at it and discovered there flaw. The only way would be to use an ListBox event and watch for the display and focus on the first of the list. A pain, but until they add the property, that is the only way to have it done automatically. Bruce ----- Original Message ----- From: David To: [email protected] Sent: Tuesday, November 29, 2011 11:15 PM Subject: Re: SimpleDialogs - Wonder what I am doing wrong Nope, BT, that won't do. FocusedItem is not a defined property or method, for SimpleDialogs; is what I am told by the error message, when trying it out. Seems to be a lack of some kind in the Toolkit code, since the first item (or any other item, for that matter), cannot be focused in a SimpleDialog. Thanks for your trying to help, though. Wish it had been that simple. ----- Original Message ----- From: BT To: [email protected] Sent: Wednesday, November 30, 2011 5:03 AM Subject: Re: SimpleDialogs - Wonder what I am doing wrong Hi Dave, Try this for focusing on the first item on the list. List items start at 1. So after loading the list do this as you have done: FileList.FocusedItem = 1 FileList.Sort = True FileList.DefaultButton = "Delete" FileList.CancelButton = "Close" ----- Original Message ----- From: David To: [email protected] Sent: Tuesday, November 29, 2011 10:21 PM 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.
