Adblock breaks this site

Vb Question...

Discussion in 'Programming General' started by Visual Basic Matt, Sep 1, 2008.

  1. Visual Basic Matt

    Visual Basic Matt Apprentice

    Joined:
    Jan 29, 2008
    Posts:
    647
    Referrals:
    2
    Sythe Gold:
    56
    Discord Unique ID:
    223154494878253056
    Vb Question...

    I'm trying to make it so that when you hover over an image another image will move to your mouse position, so that its like an icon. (I don't want it to just make the image the icon as load it from the properties message.) I want to use the image I have captions and text boxes on. So, when you hover over an object it will show the thing to edit it and it will move along with your mouse. Sorry if i didn't explain that very well, I tryied to make it as easy to understand as possible... =|
     
  2. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Vb Question...

    Do you want to replace the cursor, or place an image under it?
     
  3. Visual Basic Matt

    Visual Basic Matt Apprentice

    Joined:
    Jan 29, 2008
    Posts:
    647
    Referrals:
    2
    Sythe Gold:
    56
    Discord Unique ID:
    223154494878253056
    Vb Question...

    Just place an image under it like a tooltip text but a diferent way to display it..
     
  4. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Vb Question...

    i know what you mean, if noone has solved this when i get back ill do it for you.
     
  5. Visual Basic Matt

    Visual Basic Matt Apprentice

    Joined:
    Jan 29, 2008
    Posts:
    647
    Referrals:
    2
    Sythe Gold:
    56
    Discord Unique ID:
    223154494878253056
    Vb Question...

    Problem still awaiting a solution... :(
     
  6. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    Vb Question...

    Copy and paste this into your form, be sure to have the picture you want to hover over called Picture1 and the picture you want to appear when you hover over Picture1 called Picture2.
    Also this will only work with Picture Boxes NOT Image Boxes.

    Code:
    Option Explicit
    
    Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As Rect) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
    
    Private Type PointAPI
        X As Long
        Y As Long
    End Type
    Private Type Rect
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    
    Private Sub Form_Load()
        Me.ScaleMode = 3
    End Sub
    
    Private Sub tmrMouseOver_Timer()
        Dim blnMouseOver As Boolean
        Dim MousePos As PointAPI
        Dim wRect As Rect
        blnMouseOver = IsMouseOver(Picture1.hWnd)
        If blnMouseOver = True Then
            GetCursorPos MousePos
            GetWindowRect Me.hWnd, wRect
            Picture2.Left = (MousePos.X - wRect.Left)
            Picture2.Top = (MousePos.Y - wRect.Top)
            Picture2.Visible = True
        Else
            Picture2.Visible = False
        End If
    End Sub
    
    Private Function IsMouseOver(hWnd As Long) As Boolean
        Dim wRect As Rect
        Dim MousePos As PointAPI
        GetCursorPos MousePos
        GetWindowRect hWnd, wRect
        IsMouseOver = IIf((MousePos.X <= wRect.Right And MousePos.X >= wRect.Left) And (MousePos.Y <= wRect.Bottom And MousePos.Y >= wRect.Top), True, False)
    End Function
    I've also attached the project.
     

    Attached Files:

  7. htaed

    htaed Forum Addict
    Banned

    Joined:
    Dec 19, 2005
    Posts:
    336
    Referrals:
    0
    Sythe Gold:
    0
    Vb Question...

    Nice covey :)

    Hope it all works for you
     
  8. Visual Basic Matt

    Visual Basic Matt Apprentice

    Joined:
    Jan 29, 2008
    Posts:
    647
    Referrals:
    2
    Sythe Gold:
    56
    Discord Unique ID:
    223154494878253056
    Vb Question...

    Thanks Covey. :) You've always been a great help to me and I appreciate it greatly...

    Also, Check out the last post in my hiscore lookup thread I should be putting a newer version up there soon.
     
< Runescape Client | Login Form To Create A New Button >


 
 
Adblock breaks this site