如题

解决方案 »

  1.   

    你想干什么,如果得到焦点
    SetFocus就行了
      

  2.   

    EN_SETFOCUSvoid CTest6Dlg::OnSetfocusEdit1() 
    {
    // TODO: Add your control notification handler code here
    }
      

  3.   

    BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    if( pMsg->message == WM_LBUTTONDOWN )

    if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd)
    {
    AfxMessageBox("11");
    }
    } return CDialog::PreTranslateMessage(pMsg);
    }
      

  4.   

    这个EDIT已经有ONLBUTTONCLK(..)这个事件,我想在程序中执行这个事件
      

  5.   

    这个EDIT已经有OnLButtonDown(UINT nFlags, CPoint point) 我想在程序中执行这个事件 ,直接调用好像提示我不行。
      

  6.   

    EN_SETFOCUS,可以直接调用,我试过了,为什么你不行呢。用lixiaosan给的方法更直观。
      

  7.   

    得到焦点?响应单击事件? 使用GetDlgItem(IDC_EDIT1)->SetFocus()就能执行OnLButtonDown(UINT nFlags, CPoint point)事件了吗?
      

  8.   

    我有一个按钮和一个EDIT,我想点击按钮执行EDIT的OnLButtonDown(UINT nFlags, CPoint point)内容
      

  9.   

    直接调用的提示是: error C2248: 'OnLButtonDown' : cannot access protected member declared in class 'CVideoWin'
      

  10.   

    protected 级
    改成publicclass A
    {
      public:
        Get(){};
      protected:
        
     SetX(){};
    }A a;
    a.SetX();会报错的
      

  11.   

    #if !defined(AFX_MYEDIT_H__1C3E6E5A_C058_4BB3_A26A_05DC3E504D81__INCLUDED_)
    #define AFX_MYEDIT_H__1C3E6E5A_C058_4BB3_A26A_05DC3E504D81__INCLUDED_
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // MyEdit.h 
    class CMyEdit : public CEdit
    {
    public:
    CMyEdit();public:public:
    //{{AFX_VIRTUAL(CMyEdit)
    //}}AFX_VIRTUALublic:
    virtual ~CMyEdit();
    long xLength;
    long yLength;
    protected:
    //{{AFX_MSG(CMyEdit)
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    //{{AFX_MSG(CMyEdit)
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    private:
    POINT m_ptOld;
    };
    #endif // !defined(AFX_MYEDIT_H__1C3E6E5A_C058_4BB3_A26A_05DC3E504D81__INCLUDED_)/////////////////////////////////
    // MyEdit.cpp 
    //#include "stdafx.h"
    #include "MyEdit.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CMyEditCMyEdit::CMyEdit()
    {
    }CMyEdit::~CMyEdit()
    {
    }BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
    //{{AFX_MSG_MAP(CMyEdit)
    //}}AFX_MSG_MAP
    ON_WM_LBUTTONDOWN()
    ON_WM_LBUTTONUP()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    void CMyEdit::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    m_ptOld = point;
    ClientToScreen(&m_ptOld);
    }void CMyEdit::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    POINT ptNew = point;
    ClientToScreen(&ptNew);
    }