2012-02-06 3 views
3

MFC 대화 상자에서 버튼의 커서를 변경하려고합니다. 나는 사용했다.MFC에서 버튼의 커서 변경

BOOL CStartDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{ 
if (m_changeCursor) 
{ 
    ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND)); 
    return TRUE; 
} 

return CDialog::OnSetCursor(pWnd, nHitTest, message); 
} 

그러나 전체 대화 상자에서 커서를 변경하고있다. m_button는 CButton 클래스의 객체입니다. button.I의 커서를 변경하는 방법을 가르쳐주세요 또한이 tryed하지만

m_button1.SetCursor(::LoadCursor(NULL, IDC_HAND)); 

답변

2

를 호출 LoadCursor() 함수를 작동하지하고 CMFCButton :: SetMouseCursor() 멤버 함수의 반환 값을 전달했다. 다음은 그 예이다 :

BOOL CExerciseDlg::OnInitDialog() 
{ 
    CDialogEx::OnInitDialog(); 

    // Set the icon for this dialog. The framework does this automatically 
    // when the application's main window is not a dialog 
    SetIcon(m_hIcon, TRUE);   // Set big icon 
    SetIcon(m_hIcon, FALSE);  // Set small icon 

    // TODO: Add extra initialization here 
    m_Calculate.SetMouseCursor(LoadCursor(AfxGetInstanceHandle(), 
           MAKEINTRESOURCE(IDC_CURSOR1))); 

    return TRUE; 
} 

http://www.functionx.com/visualc/controls/mfcbtn.htm#subtitleApi CWinApp::LoadCursor

+0

이 방법은 CMFCButton 클래스 유효 참조 참조. 여기서 m_button1은 CButton 클래스의 객체입니다. – Durgesh

+1

myButton.SetCursor (:: LoadCursor (NULL, IDC_HAND)); http://msdn.microsoft.com/en-us/library/8w6ks9y7%28v=vs.80%29.aspx –