# MFC project disable copy & paste on CEdit ###### tags: `mfc` `visual studio` * CMyEdit.h ```cpp= #pragma once #include "afxwin.h" class CMyEdit : public CEdit { public: CMyEdit(); // standard constructor ~CMyEdit(); protected: afx_msg LRESULT OnPaste(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() }; ``` * CMyEdit.pp ```cpp= #include "CMyEdit.h" CMyEdit::CMyEdit(){} CMyEdit::~CMyEdit(){} BEGIN_MESSAGE_MAP(CMyEdit, CEdit) ON_MESSAGE(WM_PASTE, &CMyEdit::OnPaste) END_MESSAGE_MAP() LRESULT CMyEdit::OnPaste(WPARAM wParam, LPARAM lParam){ // Put any code here you want to execute when the user right clicks on the edit // control. Just leave it blank to disable the menu return true; } ``` 把 edit 的 IDC_EDIT 使用上面新的 CMyEdit 來使用 Edit 欄位 IDC_EDIT 就是 UI 上 edit field 元件的 ID. 需要使用自訂的 CEdit 的 cpp 上面加上: ```cpp= .h: (宣告) CMyEdit m_myEditControl; .cpp: (DoDataExchange function 加入) DDX_Control(pDX, IDC_EDIT, m_myEditControl); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up