我用MessageBox试过了这三个函数,都能执行。但光标的设置却没效果。怎么解决HCURSOR shouxing;//手型
HCURSOR jiantou; //箭头
BOOL CMyWinApp::InitInstance ()
{
shouxing = this->LoadCursorW (IDC_CURSOR1);
jiantou = this->LoadStandardCursor (IDC_ARROW);
m_pMainWnd=new CMainWindow;
m_pMainWnd->ShowWindow (SW_SHOW);
return TRUE;
}
class CTaoBao : public CStatic
{
public:
public:
afx_msg void OnMouseMove(UINT nFlags,CPoint point);
afx_msg void OnMouseHover(UINT, CPoint);
afx_msg void OnMouseLeave();
DECLARE_MESSAGE_MAP()
};
void CTaoBao::OnMouseMove (UINT,CPoint)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = this->m_hWnd ;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
::TrackMouseEvent(&tme);
}
extern HCURSOR shouxing;
void CTaoBao::OnMouseHover(UINT, CPoint)
{
this->SetCursor (shouxing);
}
extern HCURSOR jiantou;
void CTaoBao::OnMouseLeave ()
{
this->SetCursor (jiantou);
}
HCURSOR jiantou; //箭头
BOOL CMyWinApp::InitInstance ()
{
shouxing = this->LoadCursorW (IDC_CURSOR1);
jiantou = this->LoadStandardCursor (IDC_ARROW);
m_pMainWnd=new CMainWindow;
m_pMainWnd->ShowWindow (SW_SHOW);
return TRUE;
}
class CTaoBao : public CStatic
{
public:
public:
afx_msg void OnMouseMove(UINT nFlags,CPoint point);
afx_msg void OnMouseHover(UINT, CPoint);
afx_msg void OnMouseLeave();
DECLARE_MESSAGE_MAP()
};
void CTaoBao::OnMouseMove (UINT,CPoint)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = this->m_hWnd ;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
::TrackMouseEvent(&tme);
}
extern HCURSOR shouxing;
void CTaoBao::OnMouseHover(UINT, CPoint)
{
this->SetCursor (shouxing);
}
extern HCURSOR jiantou;
void CTaoBao::OnMouseLeave ()
{
this->SetCursor (jiantou);
}
void CTaoBao::OnMouseHover(UINT, CPoint)
{
SetClassLongPtr(m_hWnd, GCL_HCURSOR, NULL); //先把窗口类的光标设置为NULL
this->SetCursor (shouxing);
}extern HCURSOR jiantou;
void CTaoBao::OnMouseLeave ()
{
SetClassLongPtr(m_hWnd, GCL_HCURSOR, NULL); //先把窗口类的光标设置为NULL
this->SetCursor (jiantou);
}code]
extern HCURSOR shouxing;
void CTaoBao::OnMouseHover(UINT, CPoint)
{
SetClassLongPtr(m_hWnd, GCL_HCURSOR, NULL); //先把窗口类的光标设置为NULL
this->SetCursor (shouxing);
}extern HCURSOR jiantou;
void CTaoBao::OnMouseLeave ()
{
SetClassLongPtr(m_hWnd, GCL_HCURSOR, NULL); //先把窗口类的光标设置为NULL
this->SetCursor (jiantou);
}
void CMFCDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = this->m_hWnd ;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 2000;
::TrackMouseEvent(&tme); CDialog::OnMouseMove(nFlags, point);
}void CMFCDlg::OnMouseHover(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
SetClassLongPtr(m_hWnd, GCL_HCURSOR, NULL);
SetCursor(LoadCursor(NULL, IDC_CROSS));
CDialog::OnMouseHover(nFlags, point);
}
测试通过,完全正常.