簡體   English   中英

MFC:帶有派生 CButton 子項的 CDialogEx 在按鈕上方時不會更改 cursor?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM