Results 1 to 10 of 10

Thread: why not lostfocus?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    New Delhi, India
    Posts
    75

    Unhappy

    I have created rollover effect using few picture boxes. the problem is that there is not way to find when the lostfocus of a picturebox was triggered. As there is no event called lostfocus for picturebox, is there any way that this can be done using some APIs. any api gurus who know this. please help me

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    ...a shot in the dark
    Could you use the mouse-move event...
    on the picture one event on the form the other event
    Ie..when on form the picture is red
    ....when on the picture the picture is blue
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Try putting a Label in the picturebox, and resize it to fit the PictureBox exactly. Set it's Backstyle property to 0 - Transparent. The label has the GotDocus, LostFocus events.

    I can't think of any other way.

    Hope this helps.

  4. #4
    Guest
    Actually, there is a LostFocus event.
    Code:
    Private Sub Picture1_LostFocus()
        MsgBox ("LOST FOCUS")
    End Sub

  5. #5
    Guest
    Megatron! Congrats for reaching 3000 posts!

    And FYI, there's no LostFocus event to a PictureBox.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Actually there is, At least there is in Vb5
    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
    Guest
    Sorry, my mistake.
    There is a LostFocus event.

  8. #8
    Guest
    Sc0rp: Thanks. In VB4, 5 and 6 there are LostFocus events. Try this example. Make a Form with a CommandButton and a PictureBox. Insert this code into it.
    Code:
    Private Sub Picture1_LostFocus()
        MsgBox ("LOST FOCUS")
    End Sub
    Try clicking the PictureBox then clicking the CommandButton (so it loses focus). The MessageBox should pop up.

  9. #9
    New Member
    Join Date
    Aug 2000
    Posts
    4
    I once had the same problem. I think the actual problem is not the losing the focus, but losing the mouse_over. I think what you need is a mouse_out. That one does not exist. You could try to use the Form_MouseMove.

    [code]Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Picture1.BackColor = &HC0FFFF
    End Sub

    Private Sub Picture1_LostFocus()
    MsgBox ("lost focus")
    End Sub

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Picture1.BackColor = &H8080FF
    End Sub

    The problem is that Form_MouseMove has a short delay. It triggers only every somewhat milliseconds, that could couse that i seems like it did not work (when you move your move real quickly). In that case: also use the mouse_move of other objects...

    [Edited by JeroenA on 08-17-2000 at 11:20 AM]

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    I'm sure tppradeep18 got image box mixed with picture box
    Though the picture box has a lost focus event, it won't work for the purpose of this question.
    To engage the lostfocus event of the picture box you have to click something not just move off the image.

    The way to go is the mouse_move events as suggested above.
    use the mouse-move event...
    on the picture one event on the form the other event
    Ie..when on form the picture is red
    ....when on the picture the picture is blue
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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