Results 1 to 8 of 8

Thread: Frames that would follow the selected item in a ListBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226

    Question

    Hi there,

    I have a ListBox with > 100 items, at the same time I have a Frame which has multible CheckBoxes. The Q is:

    How can I make the frame move up/down with whichever is selected from the listbox ??

    I have this code:

    Code:
    Private Sub Form_Load()
      Frame1.Left = List1.Left + List1.Width 
      Frame1.Top = List1.Top - 180 
    End sub
    
    Private Sub List1_Click()
      Frame1.Top = List1.ListIndex * 300
    End Sub
    The 2 problems i'm having are:

    - The Listindex When it's (0) ??
    - When selecting item > 20 , the Frame would be Hidden !?


    Thanx for any help.





  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    Am I not clear enough !?
    If so, please let me know?

    Thanx.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Unfortnately, yeah, it's a bit hard to picture what you're trying to do.

    Do you want scroll the contents of the frame?
    You could also make the ckeckboxes in the listbox.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Guest
    To move only the CheckBoxes, you could set their Tag property to "1" then use a For Each loop to move them.

    Code:
    Dim MyObj As Object
    
    For Each MyObj In Form1.Controls
        If MyObj.Tag = "1" Then
            MyObj.Move MyObj.Left + 50
        End If
    Next MyObj

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    Thanx for replying.

    Yes. I want to move/scroll the whole frame with it's contents.

    The ListBox would have Only 20 items visible. When you click item # 3 I want that frame to (move) to be in the same level with the clicked item.
    The problem is: If, for example, I click item # 41 , the frame would move way below.
    Because, as you can see from the code, it takes the ListIndex * 300

    Again, Thanx.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well you could move the content as Meg showed but instead of using the tag property use Getparent api and compare it to the frame hwnd. But i would use a regular listbox, also if you have 300 checkboxes, you won't have much resources and RAM let when you run it.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226
    OK, Ok. Let me put it this way.

    How can I find the (X,Y) of the selected item in the List1_Click Event ??
    Which could be found in List1_MouseDown Event.

    Thanx.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could either store x and y from mousedown event since it will fire before click, or use getcursorpos and clienttoscreen api to get the position in pixels
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width