Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


changing mousepointer over command buttons

Posted on 2000-03-31
Medium Priority
Last Modified: 2012-06-21
  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,
Question by:DoughBoy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
LVL 32

Expert Comment

ID: 2675446
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

Expert Comment

ID: 2675583
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?

Expert Comment

ID: 2675715
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)

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

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

Industry Leaders: 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!


Accepted Solution

AshokKumar earned 400 total points
ID: 2675722
Oops. i clicked comment instead of answer. The above code is your solution friend. <Smile>
LVL 32

Expert Comment

ID: 2676025
>>>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.

Expert Comment

ID: 2676171
Erick37 - Thanks, I was wondering about that.

See 'ya,

Author Comment

ID: 2678740
Thanks very much!
It works very well.
Best Regards



Expert Comment

ID: 2678765
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.

Thanks guy. <Smile and Wink>

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

636 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