By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 802 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Change cursors...

P: 27
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
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
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

P: 1
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.