Results 1 to 8 of 8

Thread: [RESOLVED] Buttons Problem...

  1. #1

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Resolved [RESOLVED] Buttons Problem...

    Hello,
    if i make a picture box and put a picture in it and use it as a button its okay i m having o problem in this, but is it possible if mouse come over button ( havn't clicked yet ) it changes image .......

    i hope u undertsnad what im saying about
    Muhammad Furqan Attari.

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

    Re: Buttons Problem...

    In the mousemove event, simply load a different image into it.

  3. #3
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Buttons Problem...

    what he means is this:

    VB Code:
    1. Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.    
    3.     Image1.Picture = LoadPicture('your picture)
    4.  
    5. End Sub

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

    Re: Buttons Problem...

    Correct (thanks paralinx...I probably should have posted a code example ) and when the mouse leaves the picture/image control, revert it back to its original.

    Bear in mind that these images would need to be deployed with your application so make sure you include them in your setup package.

  5. #5
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Buttons Problem...

    It's all good I was going to post the code anyway but you posted before I did. What you can do for when the mouse leaves the image to put it back to the normal image or no image is this in the form:

    VB Code:
    1. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.    
    3.     Image1.Picture = 'Starting Picture or No Picture
    4.  
    5. End Sub

  6. #6

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Buttons Problem...

    hello, i successfully did that but i still have problem.....

    when mouse go over it changes picture but when mouse go from over that picture that picture doesn't come back to old one
    Muhammad Furqan Attari.

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

    Re: Buttons Problem...

    Quote Originally Posted by mfurqan
    hello, i successfully did that but i still have problem.....

    when mouse go over it changes picture but when mouse go from over that picture that picture doesn't come back to old one
    API to the rescue.
    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.  
    8. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    9. If (X < 0) Or (Y < 0) Or (X > Picture1.Width) Or (Y > Picture1.Height) Then
    10.        ReleaseCapture ' mouse is no long over picture control, so change it back to original
    11.        Picture1.Picture = LoadPicture("c:\Original.jpg")
    12. ElseIf GetCapture() <> Picture1.hwnd Then
    13.        SetCapture Picture1.hwnd 'mouse is over the picture box so change the picture to new guy
    14.        Picture1.Picture = LoadPicture("c:\NewPicture.jpg")
    15. End If
    16. End Sub
    Note: This will NOT work with an Image control. You MUST use a Picture control with this code as it requires the use of the control's hWnd property. Image controls do not have an hWnd property.
    Last edited by Hack; Oct 28th, 2005 at 07:24 AM.

  8. #8

    Thread Starter
    Addicted Member mfurqan's Avatar
    Join Date
    Oct 2005
    Location
    Pakistan
    Posts
    176

    Re: Buttons Problem...

    yeh it worked thanks
    Muhammad Furqan Attari.

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