• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

changing mousepointer over command buttons

Hi
  How do I make the mousepointer change to a finger when the mouse moves over a command button in VB?  I need to be able to do this for buttons that I currently have on forms and buttons that will be created and loaded during the application's runtime.
Thanks for your help,
DoughBoy
0
DoughBoy
Asked:
DoughBoy
  • 3
  • 2
  • 2
  • +1
1 Solution
 
Erick37Commented:
Create a Cursor in the shape you like then store it in a Resource file.  Assign it to the button like this:

Private Sub Form_Load()
    Command1.MousePointer = 99 'custom
    'Create a custom cursor and save it in a resource file
    'The ID of the cursor is the first arg to LoadResPicture
    Command1.MouseIcon = LoadResPicture(101, vbResCursor)
End Sub
0
 
FoyalCommented:
You can set the MouseIcon property of the command button to the picture you want at design time and that's all you have to do. The cursor will be saved in the form's resource file (.frx)automatically.

Erick37- Does this method use more resources?
0
 
AshokKumarCommented:
Here it goes my friend.

First create a control array. Set these at designtime for the 0 th index object as:

MouseIcon = vbHand (Choose from cursors)
MousePointer=99

Then in form load code this

For i = 1 To command1.Count - 1
    Command1(i).MouseIcon = Command1(0).MouseIcon
    Command1(i).MousePointer = Command1(0).MousePointer
Next

If u add any other control also set the same again to that control. Now it should work fine. <Smile> Get back to me


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AshokKumarCommented:
Oops. i clicked comment instead of answer. The above code is your solution friend. <Smile>
0
 
Erick37Commented:
>>>MouseIcon = vbHand ?

What is this?  Shoudn't this point to an ico file?

If you store a custom cursor in the form (frx), then it will take more resources than by using a resource file if you have more than one form with custom cursors.  It is good practice to use resource files to store cursors, icons and strings.
0
 
FoyalCommented:
Erick37 - Thanks, I was wondering about that.

See 'ya,
Foyal
0
 
DoughBoyAuthor Commented:
Thanks very much!
It works very well.
Best Regards

:)

DoughBoy
0
 
AshokKumarCommented:
Erick37
MouseIcon=VbHand  In the brackets i ahve mentioned to select from available cursors or icons. I thought it would be simpler if i say like that. Sorry if i am not clear.

DoughBoy
Thanks guy. <Smile and Wink>
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now