Solved

changing mousepointer over command buttons

Posted on 2000-03-31
8
324 Views
Last Modified: 2012-06-21
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
Comment
Question by:DoughBoy
[X]
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
8 Comments
 
LVL 32

Expert Comment

by:Erick37
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
0
 
LVL 3

Expert Comment

by:Foyal
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?
0
 

Expert Comment

by:AshokKumar
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)
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!

 

Accepted Solution

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

Expert Comment

by:Erick37
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.
0
 
LVL 3

Expert Comment

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

See 'ya,
Foyal
0
 

Author Comment

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

:)

DoughBoy
0
 

Expert Comment

by:AshokKumar
ID: 2678765
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 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