Solved

How to change the mouse icon in col in a mshflexgrid

Posted on 2014-09-07
10
143 Views
Last Modified: 2014-09-07
I have a column of links that can be clicked and want the mouse pointer to turn to a finger
Private Sub FlxGrd_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
 If Index = 2 Then
   With FlxGrd(2)
    If .Row > 0 And .Col = 0 Then
      'change Mouse Icon here
      Else
      'default MouseIcon for other cols rows
    End If
  End With
 End If
End Sub
how to do this?
0
Comment
Question by:isnoend2001
  • 5
  • 4
10 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 250 total points
ID: 40308563
Private Sub FlxGrd_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
 If Index = 2 Then
   With FlxGrd(2)
    If .Row > 0 And .Col = 0 Then
      Set.MouseIcon = LoadPicture("C:\Windows\Cursors\hmove.cur")
.MousePointer = vbCustom
      Else
      .MousePointer = vbDefault
    End If
  End With
 End If
End Sub

Open in new window

0
 
LVL 17

Assisted Solution

by:vb_elmar
vb_elmar earned 250 total points
ID: 40308585
Private Sub FlxGrd_MouseMove(index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
If index = 2 Then

With FlxGrd(2)
    kb1 = .CellWidth * (2)               ' (2) means second column
    kb2 = .CellWidth * (2) + .CellWidth  ' (2) means second column
End With
    
If x > kb1 And x < kb2 Then
    FlxGrd(2).MousePointer = 7
Else
    FlxGrd(2).MousePointer = 0
End If
End If
End Sub

Open in new window

0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40308620
I've attached a bettor cursor for my example. You'll need to rename it to Hand.cur
HAND.txt
0
 

Author Closing Comment

by:isnoend2001
ID: 40308640
Thanks that works
0
 

Author Comment

by:isnoend2001
ID: 40308686
Didn't realize it at the time, but i have the cursor in a resource file
thanks martinliss
this works
Set .MouseIcon = LoadResPicture(101, vbResCursor), however it is not limited to the first column col(0)
Thanks vb_elmar
I am trying to tweak your code to work, so far no luck
if push comes to shove i will leave the finger and just get the data from first column based on the row clicked
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 45

Expert Comment

by:Martin Liss
ID: 40308689
however it is not limited to the first column col(0)
IIf you change line 5 in my code to

Set.MouseIcon = LoadResPicture(101, vbResCursor)

doesn't it work?
0
 

Author Comment

by:isnoend2001
ID: 40308699
Yes it works good, Thank you
But  the whole grid is the finger, not just the first column(0)
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40308976
Here is working code. (Substitute your resource cursor)

Private Sub FlxGrd_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)

If Index = 2 Then

    With FlxGrd(Index)
        If x < .CellWidth Then
        Set .MouseIcon = LoadPicture("C:\temp\hand.cur")
        .MousePointer = vbCustom
    Else
        .MousePointer = vbNormal
    End If
    
    End With

End If

End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40308998
thanks martinliss

That works i could not get it to work so i had decided put it on the back burner until later
But now i don't have to
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40309000
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written (some of them updated recently) that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now