Visual C++ Question:
Download Questions PDF

How to change the Mouse Pointer Over a Button at runtime?


Assuming that you have set the button's ID as IDC_BTNSAMPLE in the resource editor :-
// You have to handle the WM_SETCURSOR message handler to do that
BOOL CTestDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
if (pWnd == GetDlgItem(IDC_BTNSAMPLE))
{ // To load a standard cursor
// To load your own custom cursor. Assuming that you have created a
// Cursor in the resource editor and named it as IDC_CURSAMPLE
// Remember to return TRUE here return TRUE;
return CDialog::OnSetCursor(pWnd, nHitTest, message);

Download Visual C++ Interview Questions And Answers PDF

Previous QuestionNext Question
How to change the Properties of a Button at runtime?Why Array Index starts from Zero?