c++.mfc - Cursor
- Phill (17/17) Mar 14 2003 Hi there
- Matthew Wilson (29/46) Mar 14 2003 When the mouse is moved over a window, it is sent the WM_SETCURSOR messa...
- Phill (20/73) Mar 15 2003 Thanks very much for your help!
- Matthew Wilson (6/88) Mar 15 2003 You're most welcome. :)
Hi there I am trying to use my own cursor throughout the entire program. I have the following code: ============================== HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); ============================== While this code works fine if I use it while catching a key or mouse event and also in the onDraw method, I cannot get it to stay after the window repaints. Ive tried onCreate also but this has no effect. Any help would be appreciated . Im new to this, as you can see Phill.
Mar 14 2003
When the mouse is moved over a window, it is sent the WM_SETCURSOR message. (Actually, the parent window is sent the message first, and if it does not return TRUE, the message is sent to the actual window itself. Naturally this is the case for multiple levels of parent/child windows.) If the window (or parent) does return TRUE, it is expected that it calls SetCursor. If not, the system deduces a cursor to set, based upon whether in client area, whether a cursor was registered as part of the window class, etc. etc. (See the documentation for WM_SETCURSOR). The catch is revealed in the documentation for SetCursor: "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. " In this case, if it is your window you should handle the WM_SETCURSOR message and do something like the following: BOOL CSomeWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(nHitTest == NTCLIENT && ... some condition, meaning that you want the cursor ...) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR2)); } else { return C<ParentWnd>::OnSetCursor(pWnd, nHitTest, message); } } "Phill" <phillbert pacific.net.au> wrote in message news:b4ua6t$o8q$1 digitaldaemon.com...Hi there I am trying to use my own cursor throughout the entire program. I have the following code: ============================== HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); ============================== While this code works fine if I use it while catching a key or mouse event and also in the onDraw method, I cannot get it to stay after the window repaints. Ive tried onCreate also but this has no effect. Any help would be appreciated . Im new to this, as you can see Phill.
Mar 14 2003
Thanks very much for your help! With your help this got the results I wanted. BOOL CMainFrame::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(TRUE){ HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); return TRUE; } return CFrameWnd::OnSetCursor(pWnd, nHitTest, message); } "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b4uha5$t6m$1 digitaldaemon.com...When the mouse is moved over a window, it is sent the WM_SETCURSORmessage.(Actually, the parent window is sent the message first, and if it does not return TRUE, the message is sent to the actual window itself. Naturallythisis the case for multiple levels of parent/child windows.) If the window (or parent) does return TRUE, it is expected that it calls SetCursor. If not, the system deduces a cursor to set, based upon whetherinclient area, whether a cursor was registered as part of the window class, etc. etc. (See the documentation for WM_SETCURSOR). The catch is revealed in the documentation for SetCursor: "If your application must set the cursor while it is in a window, makesurethe 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 timethemouse is moved. " In this case, if it is your window you should handle the WM_SETCURSOR message and do something like the following: BOOL CSomeWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(nHitTest == NTCLIENT && ... some condition, meaning that you want the cursor ...) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR2)); } else { return C<ParentWnd>::OnSetCursor(pWnd, nHitTest, message); } } "Phill" <phillbert pacific.net.au> wrote in message news:b4ua6t$o8q$1 digitaldaemon.com...eventHi there I am trying to use my own cursor throughout the entire program. I have the following code: ============================== HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); ============================== While this code works fine if I use it while catching a key or mouseand also in the onDraw method, I cannot get it to stay after the window repaints. Ive tried onCreate also but this has no effect. Any help would be appreciated . Im new to this, as you can see Phill.
Mar 15 2003
You're most welcome. :) "Phill" <phillbert pacific.net.au> wrote in message news:b4v2l3$1dc6$1 digitaldaemon.com...Thanks very much for your help! With your help this got the results I wanted. BOOL CMainFrame::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(TRUE){ HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); return TRUE; } return CFrameWnd::OnSetCursor(pWnd, nHitTest, message); } "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b4uha5$t6m$1 digitaldaemon.com...notWhen the mouse is moved over a window, it is sent the WM_SETCURSORmessage.(Actually, the parent window is sent the message first, and if it doeswhetherreturn TRUE, the message is sent to the actual window itself. Naturallythisis the case for multiple levels of parent/child windows.) If the window (or parent) does return TRUE, it is expected that it calls SetCursor. If not, the system deduces a cursor to set, based uponinclass,client area, whether a cursor was registered as part of the windowetc. etc. (See the documentation for WM_SETCURSOR). The catch is revealed in the documentation for SetCursor: "If your application must set the cursor while it is in a window, makesurethe 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 timethemouse is moved. " In this case, if it is your window you should handle the WM_SETCURSOR message and do something like the following: BOOL CSomeWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(nHitTest == NTCLIENT && ... some condition, meaning that you want the cursor ...) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR2)); } else { return C<ParentWnd>::OnSetCursor(pWnd, nHitTest, message); } } "Phill" <phillbert pacific.net.au> wrote in message news:b4ua6t$o8q$1 digitaldaemon.com...eventHi there I am trying to use my own cursor throughout the entire program. I have the following code: ============================== HCURSOR hCursor; hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2); SetCursor(hCursor); ============================== While this code works fine if I use it while catching a key or mouseand also in the onDraw method, I cannot get it to stay after the window repaints. Ive tried onCreate also but this has no effect. Any help would be appreciated . Im new to this, as you can see Phill.
Mar 15 2003