Am I going mad? 
Author Message
 Am I going mad?

Hi all,

Think I spent too much time behind the computer...

I have a project with a FileListbox object on it, and a button that selects all the files in the list.  I wanted to set the same
listindex property and index property after execution the same as it was before.

Private Sub cmdSelectAll_Click()
    OldTop = File1.TopIndex
    OldIndex = File1.ListIndex
    For n = 0 To File1.ListCount - 1
        File1.Selected(n) = True
    Next
    File1.SetFocus
    File1.ListIndex = OldIndex
    File1.TopIndex = OldTop
End Sub

I get an error 381 (Invalid Property Array Index).  The value n contains a valid item however.  It's not -1 or something.  Anyone
any idea?  I'm looking over it i guess :)

Thanks in advance
Guy




Mon, 31 Jan 2005 23:17:19 GMT  
 Am I going mad?

Tried your code and it worked well no errors.
Don't need the setfocus either. Why is it there?



Quote:
> Hi all,

> Think I spent too much time behind the computer...

> I have a project with a FileListbox object on it, and a button that

selects all the files in the list.  I wanted to set the same
Quote:
> listindex property and index property after execution the same as it was
before.

> Private Sub cmdSelectAll_Click()
>     OldTop = File1.TopIndex
>     OldIndex = File1.ListIndex
>     For n = 0 To File1.ListCount - 1
>         File1.Selected(n) = True
>     Next
>     File1.SetFocus
>     File1.ListIndex = OldIndex
>     File1.TopIndex = OldTop
> End Sub

> I get an error 381 (Invalid Property Array Index).  The value n contains a

valid item however.  It's not -1 or something.  Anyone
Quote:
> any idea?  I'm looking over it i guess :)

> Thanks in advance
> Guy





Tue, 01 Feb 2005 01:00:45 GMT  
 Am I going mad?
bool inline response();

Quote:
> Private Sub cmdSelectAll_Click()
>     OldTop = File1.TopIndex
>     OldIndex = File1.ListIndex
>     For n = 0 To File1.ListCount - 1
>         File1.Selected(n) = True
>     Next
>     File1.SetFocus
>     File1.ListIndex = OldIndex
>     File1.TopIndex = OldTop
> End Sub

> I get an error 381 (Invalid Property Array Index).  The value n contains a

valid item however.  It's not -1 or something.  Anyone

Quote:
> any idea?  I'm looking over it i guess :)

the ListIndex property dosen't function the same when multiple items
selected. As long as you have the TopIndex set right, you really have no
need to set the listIndex property, since no one item is focused on now
anyway.

sry, no can do -- I have a severe case spamigitis congestion (fear of
getting more spam) JK... LOL



Tue, 01 Feb 2005 00:59:16 GMT  
 Am I going mad?
Your code will only work for singleselect filelist boxes. I'm looking for a
solution to the same problem here.


Quote:
> Hi all,

> Think I spent too much time behind the computer...

> I have a project with a FileListbox object on it, and a button that

selects all the files in the list.  I wanted to set the same
Quote:
> listindex property and index property after execution the same as it was
before.

> Private Sub cmdSelectAll_Click()
>     OldTop = File1.TopIndex
>     OldIndex = File1.ListIndex
>     For n = 0 To File1.ListCount - 1
>         File1.Selected(n) = True
>     Next
>     File1.SetFocus
>     File1.ListIndex = OldIndex
>     File1.TopIndex = OldTop
> End Sub

> I get an error 381 (Invalid Property Array Index).  The value n contains a

valid item however.  It's not -1 or something.  Anyone
Quote:
> any idea?  I'm looking over it i guess :)

> Thanks in advance
> Guy





Tue, 01 Feb 2005 15:56:32 GMT  
 Am I going mad?
On Fri, 16 Aug 2002 09:56:32 +0200, "Cees Harlaar"

Quote:

>Your code will only work for singleselect filelist boxes. I'm looking for a
>solution to the same problem here.

How about this pseudo

List11_keydown(extravagant parameters)
        if SendMessage(getitemfrompoint_shabang) <> -1 Then
                List1.tag = whatver_above_shebang_returned
                else
                        file1.tag = ""
        endif
End sub        

( i'm too lazy to try, but confident that it may, possibly, perhaps
work unless the filelistbox doesn't process LB messages)  
I'll have another beer, then i migh try it.. :)

Regards, Frank



Tue, 01 Feb 2005 16:32:05 GMT  
 Am I going mad?


I sober up way too quick. More beer is needed.

Option Explicit

Private Const LB_ITEMFROMPOINT = &H1A9
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
As Any) As Long

Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    Dim ret As Long
    Dim pos As Long
    If Button = vbLeftButton Then
        pos = ScaleX(X, Me.ScaleMode, vbPixels) + ScaleY((Y * 65536),
Me.ScaleMode, vbPixels)
        ret = SendMessage(File1.hwnd, LB_ITEMFROMPOINT, 0&, ByVal pos)
    End If
    File1.Tag = ret
End Sub

Regards, Frank



Tue, 01 Feb 2005 17:14:39 GMT  
 Am I going mad?
I found a way out of this missery

In the declarations section of the form:
Private Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, _
    ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const LB_SETSEL = &H185
Private Const LB_SETTOPINDEX = &H197

In the code

Private Sub cmdSelectAll_Click()
    dim lngreturn as long
    dim oldindex as long
    dim oldtop as long
    OldTop = File1.TopIndex
    OldIndex = File1.ListIndex
    'Selects all items in the filelistbox, what you were doing in your loop.
    lngReturn = SendMessageBynum(File1.hwnd, LB_SETSEL, 1, -1)
    'viewport doesn't change.
    File1.SetFocus

End Sub


Quote:


> I sober up way too quick. More beer is needed.

> Option Explicit

> Private Const LB_ITEMFROMPOINT = &H1A9
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
> As Any) As Long

> Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As
> Single, Y As Single)
>     Dim ret As Long
>     Dim pos As Long
>     If Button = vbLeftButton Then
>         pos = ScaleX(X, Me.ScaleMode, vbPixels) + ScaleY((Y * 65536),
> Me.ScaleMode, vbPixels)
>         ret = SendMessage(File1.hwnd, LB_ITEMFROMPOINT, 0&, ByVal pos)
>     End If
>     File1.Tag = ret
> End Sub

> Regards, Frank



Tue, 01 Feb 2005 19:27:52 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. PLEASE, PLEASE HELP, am I going MAD - Generating Totals

2. Am I going mad??

3. help i am going mad

4. Refresh - is it logical or am I going mad?

5. ASIC's BLOAD AND BSAVE ARE NOT COMPATIBLE (OR AM I GOING MAD?)

6. Am I going MAD ? MTS for win98 ?

7. I AM GETTING MAD AT THIS

8. I AM GETTING MAD AT THIS !!!!!

9. Going mad over received mail

10. Combobox Gone Mad

11. Major Bug in VB.NET (or i've gone mad)

12. ARRRRRGH Access cross over going mad HELP!

 

 
Powered by phpBB® Forum Software