rt

解决方案 »

  1.   

    县派生CEdit类然后在派生类处理WM_KEYDOWN消息函数判断当按键式 CTRL的时候是干啥
      

  2.   

    #if !defined(AFX_MYEDIT_H__AA01B7BD_793C_4757_AF32_0624AFAB3DF8__INCLUDED_)
    #define AFX_MYEDIT_H__AA01B7BD_793C_4757_AF32_0624AFAB3DF8__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // Myedit.h : header file
    ///////////////////////////////////////////////////////////////////////////////
    // Myedit windowclass Myedit : public CEdit
    {
    // Construction
    public:
    Myedit();// Attributes
    public:// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(Myedit)
    public:
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~Myedit(); // Generated message map functions
    protected:
    //{{AFX_MSG(Myedit)
    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYEDIT_H__AA01B7BD_793C_4757_AF32_0624AFAB3DF8__INCLUDED_)
      

  3.   

    // Myedit.cpp : implementation file
    //#include "stdafx.h"
    #include "dlg.h"
    #include "Myedit.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // MyeditMyedit::Myedit()
    {
    }Myedit::~Myedit()
    {
    }
    BEGIN_MESSAGE_MAP(Myedit, CEdit)
    //{{AFX_MSG_MAP(Myedit)
    ON_WM_KEYDOWN()
    ON_WM_KEYUP()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // Myedit message handlersvoid Myedit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
    {
    //if(nChar==VK_CONTROL)
    //MessageBox("OnKeyDown--VK_CONTROL",0,MB_OK);
    CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
    }void Myedit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
    { //if(nChar==VK_CONTROL)
    //MessageBox("OnKeyUp--VK_CONTROL",0,MB_OK);
    CEdit::OnKeyUp(nChar, nRepCnt, nFlags);
    }BOOL Myedit::PreTranslateMessage(MSG* pMsg) 
    {
    if(pMsg->wParam==VK_CONTROL )
    MessageBox("PreTranslateMessage--VK_CONTROL",0,MB_OK);
    return CEdit::PreTranslateMessage(pMsg);
    }