mike_marquet
asked on
How to change an application mouse cursor !
I have an MDI application.
How can I change the mouse cursor of the global application.
By default, the cursor is an arrow but I want to change it
I have try to use SetClassLong(m_hWnd, GCL_HCURSOR, hMyCursor), but works only for the owner view of the m_hWnd. That meens, that if I go to an other view, the cursor return to default.
Can someone help me !
How can I change the mouse cursor of the global application.
By default, the cursor is an arrow but I want to change it
I have try to use SetClassLong(m_hWnd, GCL_HCURSOR, hMyCursor), but works only for the owner view of the m_hWnd. That meens, that if I go to an other view, the cursor return to default.
Can someone help me !
ASKER
I think there is an other solution but how ?
Doing this for each windows is to lot of works.
Doing this for each windows is to lot of works.
I don't know any other method.
I know it is crude but you will only have a few different window classes (OnCreate of each class?).
I know it is crude but you will only have a few different window classes (OnCreate of each class?).
there are two methods
first one changes the cursor dynamically
second one changes it at the time of creation
1.
BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if ( m_ChangeCursor )
{
::SetCursor(AfxGetApp()->L oadStandar dCursor(ID C_WAIT));
return TRUE;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
2.
BOOL CMyView::PreCreateWindow(C REATESTRUC T& cs)
{
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, // use any window styles
AfxGetApp()->LoadStandardC ursor(IDC_ WAIT),
(HBRUSH) (COLOR_WINDOW + 1)); // background brush
return CView::PreCreateWindow(cs)
}
first one changes the cursor dynamically
second one changes it at the time of creation
1.
BOOL CMyView::OnSetCursor(CWnd*
{
if ( m_ChangeCursor )
{
::SetCursor(AfxGetApp()->L
return TRUE;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
2.
BOOL CMyView::PreCreateWindow(C
{
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, // use any window styles
AfxGetApp()->LoadStandardC
(HBRUSH) (COLOR_WINDOW + 1)); // background brush
return CView::PreCreateWindow(cs)
}
ASKER
I must do it dynamically but using OnSetCursor message is also a lot of work because I must do it for all views in my application (I know this method). But my question is how to change it for the global application using a simple method (1 function only, ex. : SetApplCursor which not exist).
If there is no other simple solution, then I must do such a work
If there is no other simple solution, then I must do such a work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The system automatically displays the class cursor (the cursor associated with the window to which the cursor is pointing).