CWnd::OnLButtonDown afx_msg void OnLButtonDown( UINT nFlags, CPoint point );ParametersnFlagsIndicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down. MK_LBUTTON Set if the left mouse button is down. MK_MBUTTON Set if the middle mouse button is down. MK_RBUTTON Set if the right mouse button is down. MK_SHIFT Set if the SHIFT key is down. pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.ResThe framework calls this member function when the user presses the left mouse button.Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. ///////////////////////////////////////////////////////////// CWnd::OnLButtonUp afx_msg void OnLButtonUp( UINT nFlags, CPoint point );ParametersnFlagsIndicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down. MK_MBUTTON Set if the middle mouse button is down. MK_RBUTTON Set if the right mouse button is down. MK_SHIFT Set if the SHIFT key is down. pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.ResThe framework calls this member function when the user releases the left mouse button.Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );ParametersnFlagsIndicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the SHIFT key is down.
pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.ResThe framework calls this member function when the user presses the left mouse button.Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
/////////////////////////////////////////////////////////////
CWnd::OnLButtonUp
afx_msg void OnLButtonUp( UINT nFlags, CPoint point );ParametersnFlagsIndicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the SHIFT key is down.
pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.ResThe framework calls this member function when the user releases the left mouse button.Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
要是VC,classwizard不行么
你可以按照以下的步骤来响应OnLButtonDown和OnLButtonUp消息:
1)
打开“视图(即view)”菜单下的"ClassWizard..." 选项,或者是直接按下
“Ctrl+W”键。
2)
在弹出的”类向导“对话框中选择”消息映射(即Message Maps)“选项卡,
然后在”类名(即Class name)“组合框中选择你所要响应消息的类,此时要注意的是在”对象IDs(即Object IDs)“列表框中选择第一项,即你所要响应类的类名,此时你会看到在该对话框的右侧将会出现该类所有可用的消息,
在此你分别选择WM_LBUTTONDOWN 和 WM_LBUTTONUP两项,然后再分别按下”确定“键即可。
是否必须从CButton派生一个类呢?
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
if (uMsg == WM_LBUTTONDOWN) {
} else if (uMsg == WM_LBUTTONUP) {
}
}//
SetWindowLong(pYourDlg->m_hWnd, GWL_WNDPROC, WindowProc);