void TGIBTN::OnMouseMove (WORD x, WORD y, UINT nKey)
{
if(!bTrackLeave)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = hWnd;
tme.dwFlags = TME_LEAVE;
_TrackMouseEvent(&tme);
bTrackLeave = TRUE;
//------------------
}
}
错误提示:
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
gibutton.cpp
g:\test\gibutton.cpp(448) : error C2065: 'TRACKMOUSEEVENT' : undeclared identifier
g:\test\gibutton.cpp(448) : error C2146: syntax error : missing ';' before identifier 'tme'
g:\test\gibutton.cpp(448) : error C2065: 'tme' : undeclared identifier
g:\test\gibutton.cpp(449) : error C2228: left of '.cbSize' must have class/struct/union type
g:\test\gibutton.cpp(450) : error C2228: left of '.hwndTrack' must have class/struct/union type
g:\test\gibutton.cpp(451) : error C2228: left of '.dwFlags' must have class/struct/union type
g:\test\gibutton.cpp(451) : error C2065: 'TME_LEAVE' : undeclared identifier
g:\test\gibutton.cpp(452) : error C2065: '_TrackMouseEvent' : undeclared identifier
Error executing cl.exe.gibutton.obj - 8 error(s), 0 warning(s)
另外,我自己写了个累,没有从另外的类派生。怎么在自己的类中写消息声明,我这么写,出错
BEGIN_MESSAGE_MAP(TGIBTN)
//{{AFX_MSG_MAP(TGIBTN)
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
错误:
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
gibutton.cpp
g:\test\gibutton.cpp(33) : error C2146: syntax error : missing ';' before identifier 'ON_MESSAGE'
g:\test\gibutton.cpp(33) : fatal error C1004: unexpected end of file found
Error executing cl.exe.gibutton.obj - 2 error(s), 0 warning(s)
{
if(!bTrackLeave)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = hWnd;
tme.dwFlags = TME_LEAVE;
_TrackMouseEvent(&tme);
bTrackLeave = TRUE;
//------------------
}
}
错误提示:
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
gibutton.cpp
g:\test\gibutton.cpp(448) : error C2065: 'TRACKMOUSEEVENT' : undeclared identifier
g:\test\gibutton.cpp(448) : error C2146: syntax error : missing ';' before identifier 'tme'
g:\test\gibutton.cpp(448) : error C2065: 'tme' : undeclared identifier
g:\test\gibutton.cpp(449) : error C2228: left of '.cbSize' must have class/struct/union type
g:\test\gibutton.cpp(450) : error C2228: left of '.hwndTrack' must have class/struct/union type
g:\test\gibutton.cpp(451) : error C2228: left of '.dwFlags' must have class/struct/union type
g:\test\gibutton.cpp(451) : error C2065: 'TME_LEAVE' : undeclared identifier
g:\test\gibutton.cpp(452) : error C2065: '_TrackMouseEvent' : undeclared identifier
Error executing cl.exe.gibutton.obj - 8 error(s), 0 warning(s)
另外,我自己写了个累,没有从另外的类派生。怎么在自己的类中写消息声明,我这么写,出错
BEGIN_MESSAGE_MAP(TGIBTN)
//{{AFX_MSG_MAP(TGIBTN)
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
错误:
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
gibutton.cpp
g:\test\gibutton.cpp(33) : error C2146: syntax error : missing ';' before identifier 'ON_MESSAGE'
g:\test\gibutton.cpp(33) : fatal error C1004: unexpected end of file found
Error executing cl.exe.gibutton.obj - 2 error(s), 0 warning(s)
#define WINVER 0x0400 即可2. 如果需要自己写类,要么注意从CWnd继承,要么改为如下代码BEGIN_MESSAGE_MAP(TGIBTN, CWnd)
...
END_MESSAGE_MAP()当然在TGIBTN的头文件里TGIBTN类必须从CWnd继承,也可以是CButton之类的,只需把上述代码中的CWnd改为CButton
//**************************
//* Track Mouse Movement *
//**************************
TRACKMOUSEEVENT tme;
memset( &tme, 0, sizeof(TRACKMOUSEEVENT) );
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = m_hWnd ;
m_bTracking = _TrackMouseEvent( &tme );
BEGIN_MESSAGE_MAP(TGIBTN,没父类)
//{{AFX_MSG_MAP(TGIBTN)
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()还有 我不用stdafx.h,直接用WINDOWS。H,我在WINDOWS。H后面和前面分别试了加入#define WINVER 0x0400,还是有问题,提示的意思是没有声明TrackMouseEvent