Click to See Complete Forum and Search --> : Cursor Handling


Don Janik
April 23rd, 1999, 02:38 PM
My app has a tool palette. The user selects a tool and then moves the cursor over the document. The cursor changes to a new shape when it is over my document, and turns back to an arrow when it moved off. GOOD. While the cursor is on the document I capture it so that while the user is moving it on the document it wont flicker. When its moved off the document I release it. GOOD. Problem, How can I access the menu hot keys in this senario (the dont work while the mouse is captured yet if I dont capture the mouse the cursor flickers when moved accross my document.) How should I do the cursor handling. I currently have an adjust cursor routine in my view class and its called from my apps OnIdle. When should I capture and release the cursor so that it doesnt flicker and the menu keys are still available??

Thankyou for your help.
Don

Don Janik
April 23rd, 1999, 06:19 PM
Turns out that the app wizard and MFC by default set your cursor to be an arrow. If you want your app to have multiple cursors then you must set the default cursor to NULL. If you dont the cursor will flicker when you move the mouse. You should call AfxRegisterWndClass and set the cursor parameter to null. Here is the code to show how to do this. With this done the cursor will be stable AND you will have access to the menu hot keys.


BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs

// AfxRegisterWndClass solves my cursor problems, the following comment is from the MSDN CD.

// If your application must set the cursor while it is in a window, make sure the class cursor
// for the specified window's class is set to NULL. If the class cursor is not NULL,
// the system restores the class cursor each time the mouse is moved.

// The second NULL sets the class cursor. This stops the cursor flicker problem.
// The background color of the window is LTGRAY_BRUSH

cs.lpszClass = AfxRegisterWndClass( NULL, NULL, (HBRUSH) GetStockObject(LTGRAY_BRUSH));

return CView::PreCreateWindow(cs);
}