Results 1 to 7 of 7

Thread: Icon border

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Hi, I want to make an icon have a border when the user moves their mouse over it. I can do this in mousemove. When the user leaves it, it should return to no border. If it's near the top of a frame, then using imgTest.borderstyle = 0 in the frame's mousemove doesn't remove the border if you move very quickly above the icon and frame. Apparently, the frame's mousemove event doesn't fire when moved over for such a short time. Is there an easy way in vb to handle this or am I stuck either subclassing or using a timer and api's?

    Thanks in advance,
    Wade
    Wade

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Arrow


    Apparently, the frame's mousemove event doesn't fire when moved over for such a short time.
    I think you shoud post some code, or could say something like this:
    How on earth do you move your cursor without firing the event of the object that is parent to the control(picturebox or whatever you're using) cuz the event that fires to remove the border shoud be in 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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Here's the simple code:
    It's an image control within a frame. In the image:
    Code:
    Private Sub imgDividr_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        imgDividr.BorderStyle = 1  'Place Border on Image
    End Sub
    In the frame:
    Code:
    Private Sub Frame2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        imgDividr.BorderStyle = 0  'Remove Border
    End Sub
    The image is near the top of the frame (Top = 120). Move up too fast from the icon and out of the frame and the border sometimes stays.

    Thanks,
    Wade

    Wade

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Post

    1. Easy way: You can move this icon a bit more downwards
    2. Medium way: Put the same event in the form or frame that contains the frame containing your icon.
    3. Hard way: Timer. (You could enable=true it only when cursor enters the the icon, and false when it exits.

    Also, I would set all these to easy way
    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    1 and 2 won't allow me to put it near the edge of the form (I had tried that). Here's what I did with 3. In image:
    Code:
    Private Sub imgDividr_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    imgDividr.BorderStyle = 1
    Timer1.Enabled = True
    End Sub
    In timer (interval = 1000):
    Code:
    Private Sub Timer1_Timer()
    imgDividr.BorderStyle = 0
    Timer1.Enabled = False
    End Sub
    But the user has to keep moving the mouse or the border disappears while they're still on it.
    Maybe I'll just use API in a timer that checks the position of the mouse to determine if the border should be removed.

    Wade

  6. #6
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

    Lightbulb

    I guess you could ue a picturebox control instead and use the gotfocus and lostfoucs events but...

    The disadvantegs are size of control, the picturebox is heavyweight compared to the image

    DocZaf
    {;->

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Talking

    Eh, argh, you wont get any events, I didn't think about that. But you can use som API to get the pointer position to use within your timer.

    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Type POINTAPI
    X As Long
    Y As Long
    End Type
    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