Results 1 to 7 of 7

Thread: msgbox when focus is lost on picturebox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    msgbox when focus is lost on picturebox

    how do i make it so when the mouse is not on a picturebox anymore, it gives the user a msgbox. i tried using the lostfocus function, but it doesnt seem to do anything.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: msgbox when focus is lost on picturebox

    How about the MouseMove event?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: msgbox when focus is lost on picturebox

    that's only when the mouse is still on the picturebox right? i tried that and did msgbox "hello", and it only pops up hello when it's ON it. how do i make it pop "HELLO" once it leaves the picturebox(i want to make a msgbox pop right away when the mouse leaves the picturebox)

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: msgbox when focus is lost on picturebox

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    4. Private Declare Function ReleaseCapture Lib "user32" () As Long
    5. Private Declare Function GetCapture Lib "user32" () As Long
    6.  
    7. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8. If (X < 0) Or (Y < 0) Or (X > Picture1.Width) Or (Y > Picture1.Height) Then
    9.        ReleaseCapture
    10.        MsgBox "The mouse is no longer over the picture control"
    11. ElseIf GetCapture() <> Picture1.hwnd Then
    12.        SetCapture Picture1.hwnd
    13.        'the mouse is over the picture control
    14.        'if you want to do something when this happens
    15.        'here is where you would put your code.
    16. End If
    17. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: msgbox when focus is lost on picturebox

    thanks so much

  6. #6
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: msgbox when focus is lost on picturebox

    VB Code:
    1. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    2. Private Declare Function ReleaseCapture Lib "user32" () As Long
    3. Private Declare Function GetCapture Lib "user32" () As Long
    Hack!! can u plz explain the function of these 3 functions??
    thnx
    Show Appreciation. Rate Posts.

  7. #7
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: msgbox when focus is lost on picturebox

    You can download API Guide, it will explain all API functions.

    http://www.mentalis.org/index2.shtml
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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