Getting the cursor to change
-
I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph
-
I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph
You need to handle the message WM_SETCURSOR via the virtual handler OnSetCursor. The function is called repeatedly, so it should be optimized. In this handler and in the OnMouseMove handler is where you would call SetCursor. onwards and upwards...
-
I am using SetCursor and LoadCursor to change the cursor. m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON)); m_hOldCursor = SetCursor(m_hCursor); I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change.... Anyone? Thanks Ralph
Try this code:
BOOL CSystemTray::SetIcon(UINT nIDBigIcon, UINT nIDSmallIcon, CStatic *pWndList, int nListNumber) { ASSERT (!nListNumber || (NULL != pWndList)); m_hIcon = AfxGetApp()->LoadIcon(nIDBigIcon); m_hSmallIcon = AfxGetApp()->LoadIcon(nIDSmallIcon); ASSERT ((NULL != m_hIcon) && (INVALID_HANDLE_VALUE != m_hIcon)); ASSERT ((NULL != m_hSmallIcon) && (INVALID_HANDLE_VALUE != m_hSmallIcon)); if ((NULL == m_hIcon) || (INVALID_HANDLE_VALUE == m_hIcon) || (NULL == m_hSmallIcon) || (INVALID_HANDLE_VALUE == m_hSmallIcon)) return FALSE; CDialog::SetIcon (m_hIcon, TRUE); CDialog::SetIcon (m_hSmallIcon, FALSE); //Aggiornamento lista icone if (nListNumber && (NULL == pWndList)) return FALSE; int i; CStatic *pPt = pWndList; for (i = 0; i < nListNumber; i++, pPt++) { pPt->SetIcon (m_hIcon); } return TRUE; }
where:protected: HANDLE m_hCompletion; HICON m_hSmallIcon; HICON m_hIcon;
This works great. I did not test it with icons loaded from different modules neither with string-named resources (only index-named ones). Hope this help. Regards, Andrea