[英]MFC: CDialogEx with derived CButton child won't change cursor when over the button?
我希望在 CDialogEx window 上禁用CDialogEx
,但在從CButton
派生的子按鈕上顯示標准 cursor 時。
To get the mouse cursor to not show up, I had to override the WM_SETCURSOR
message (registering a class with a NULL
cursor didn't work).
BOOL CMyDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (nHitTest==HTCLIENT) {
::SetCursor(NULL);
return TRUE;
}
return CDialogEx::OnSetCursor(pWnd, nHitTest, message);
}
在子按鈕上我有:
BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
HCURSOR hcursor=::LoadCursor(NULL, IDC_ARROW);
SetCursor(hcursor);
return TRUE;
}
但是鼠標 cursor 在按鈕上方沒有出現? 按鈕 function 被調用。 我究竟做錯了什么?
謝謝。
將CMyButton::OnSetCursor
中的SetCursor()
調用更改為使用::SetCursor(hcursor)
。 原因是CButton::SetCursor()
沒有設置 cursor,它將圖像設置為BM_SETIMAGE
(可能很奇怪)。
BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
HCURSOR hcursor=::LoadCursor(NULL, IDC_ARROW);
::SetCursor(hcursor);
return TRUE;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.