468,512 Members | 1,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Change cursors...

Hey,

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);
SetCursor(lhCursor);
....
}
Sep 28 '06 #1
2 3614
Banfa
9,056 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 NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.