471,850 Members | 871 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,850 software developers and data experts.

Change cursors...


I'm trying to change the cursor in my application when a certain toolbar option is selected. I am using the following code which compiles and runs but does not change the cursor! I don't know why? I am using Visual C++ 6.0. IDC_GRAB is a cursor resource that I have created.

Any help would be really appreciated.
Thanks in advance.

void CProject::OnButtonGrab(){
HCURSOR lhCursor;

lhCursor = AfxGetApp()->LoadCursor(IDC_GRAB);
Sep 28 '06 #1
2 3762
9,065 Expert Mod 8TB
The Windows system changes the cursor back to the default whenever the mouse moves

You need to either call SetCursor everytime the mouse moves or change the default cursor which is part of the class(not C++ class Windows class) of your window and accessed through SetClassLong.
Sep 28 '06 #2
In OnInitDialog() add following code to change the cursor for your dialog.

SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_CURSOR1)));

You can add same code if you want to change the cursor on different events using different cursor resources.
Apr 15 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Craig | last post: by
4 posts views Thread by Maria | last post: by
4 posts views Thread by GatorBait | last post: by
3 posts views Thread by Steve Long | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.