谢谢!

解决方案 »

  1.   

    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.
      

  2.   

    不会吧,(揉揉眼睛)
    要是VC,classwizard不行么
      

  3.   

    其实这个比较简单,只要你所要响应消息的类是从CWnd类中派生出来的就可以了,
    你可以按照以下的步骤来响应OnLButtonDown和OnLButtonUp消息:
    1)
    打开“视图(即view)”菜单下的"ClassWizard..." 选项,或者是直接按下
    “Ctrl+W”键。
    2)
    在弹出的”类向导“对话框中选择”消息映射(即Message Maps)“选项卡,
    然后在”类名(即Class name)“组合框中选择你所要响应消息的类,此时要注意的是在”对象IDs(即Object IDs)“列表框中选择第一项,即你所要响应类的类名,此时你会看到在该对话框的右侧将会出现该类所有可用的消息,
    在此你分别选择WM_LBUTTONDOWN 和 WM_LBUTTONUP两项,然后再分别按下”确定“键即可。
      

  4.   

    ClassWizard中按钮只有click消息,我想响应按下和弹起的消息,谢谢
      

  5.   

    可默认情况下,按钮的按下和弹起消息并没有发给父窗口。
    是否必须从CButton派生一个类呢?
      

  6.   

    或者重载PreTranslateMessage虚函数,再做处理
      

  7.   

    添加WindowProc映射,在里面用(LWORD)lParam来判断
      

  8.   

    派生一个类,使他的基类是CButton,然后响应OnLButtonDown 和 OnLButtonUp
      

  9.   

    还有一种方法:窗口子类化你先声明一个窗口过程来处理消息:
    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);
      

  10.   

    你是指在什么地方响应这两个消息?对MFC下的窗口不是很简便么?在ClassWizard里重载WM_LBUTTONDOWN和WM_LBUTTONUP消息就行了。