【问题】
I am developing a small application in MFC... there is a little problem..hope you guys would help me regarding this...Here we go..the problem is...I have 6 little edit control(Text box) in which I will allow the user to enter some numbers..I have limited the number of chars/textbox as 4 but its allowing the user to copy and paste n numbers....How do I restrict the copy paste option in an Edit control....Please help me...
【答案】
I found 2 ways of solving the problem....please check the below...
1st method:
class CNoPasteEdit: public CEdit
{
public:
CNoPasteEdit();
~CNoPasteEdit();
protected:
// This line will need to be added by hand because WM_PASTE is not available in
// class wizard
afx_msg void OnPaste(WPARAM wParam, LPARAM lParam);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
DECLARE_MESSAGE_MAP()
};
Then you will need to edit the .cpp file for this class like so
CNoPasteEdit::CNoPasteEdit(){
// Put any construction code here
}
CNoPasteEdit:~:CNoPasteEdit(){
// Put any destruction code here
}
BEGIN_MESSAGE_MAP(CNoPasteEdit, CEdit)
// This line is needed because there is no default macro for WM_PASTE messages
// This line will also need to be added by hand
ON_MESSAGE(WM_PASTE, OnPaste)
ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
void CNoPasteEdit::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
}
void CNoPasteEdit::OnContextMenu(CWnd* pWnd, CPoint point){
// Put any code here you want to execute when the user tries to paste into the edit
// conrtol. Just leave it blank to prevent pasting.
}
2nd method: Handle the ON_EN_CHANGE event and capture the text in the CString and check if its more than the limited character..if its..you can clear the text box with a warning message...
来自:https://*.com/questions/2316041/how-to-restrict-copy-paste-in-a-textbox-in-mfc
how to restrict copy paste in a Textbox, in MFC?的更多相关文章
-
Perform Cut Copy Paste Operations Using Cut_Region Copy_Region Paste_Region Commands In Oracle Forms
You can do Select, Cut, Copy and Paste operations on text items in Oracle Forms using Select_All, Cu ...
-
eclipse cut copy paste plugin
The Cut Copy Paste Plus plug-in enhances the standard Cut, Copy and Paste commands in Eclipse IDE. W ...
-
Copy Paste DWG to older 3ds Max
Hi, This is quick tutorial: how to install Auto Cad scripts to be able to copy from newer Auto Cad t ...
-
vim - copy/paste a word
1. http://*.com/questions/7797068/copying-a-word-and-pasting-over-a-word viwp - visually ...
-
兼容Android 和 ios JavaScript copy paste
<!DOCTYPE html> <html> <head> <title>关于我们Frame</title> <meta charse ...
-
ubuntu terminal copy paste
copy: ctrl + insert paste: shift + insert
-
Pyperclip could not find a copy/paste mechanism for your system.
sudo apt-get install xsel sudo apt-get install xclip pip install gtk to install the gtk Python modul ...
-
【Android】Android之Copy and Paste
Android为复制粘贴提供了一个强大的基于剪切板的框架,它支持简单和复杂的数据类型,包括纯文本,复杂的数据结构,二进制流,甚至app资源文件.简单的文本数据直接存储在剪切板中,而复杂的数据则存储的是 ...
-
In line copy and paste to system clipboard
On the Wiki Wiki Activity Random page Videos Photos Chat Community portal To do Contribute Watch ...
随机推荐
-
c# 局域网文件传输实例
一个基于c#的点对点局域网文件传输小案例,运行效果截图 //界面窗体 using System;using System.Collections.Generic;using System.Compon ...
-
WCF简单使用(分别部署在控制台和IIS上)
WCF部署到控制台 1.下面通过一个简单的服务示例来认识WCF1.新建项目,名称IBLL,解决方案名称WcfDemo,模板选择类库2.修改Class1.cs文件名称为 IUserInfoService ...
-
poj2612Mine Sweeper
很简单的模拟题目,但在队内赛的时候一直WA了10发...我ca 题目没看懂,也不算,就是我以为摸到地雷他会标星(*) ,但其实还是(x),T_T #include <cstdio> #in ...
-
C# 获取地址栏的地址(URL)
原文地址:http://blog.csdn.net/dingxingmei/article/details/8448009 设当前页完整地址是:http://www.jb51.net/aaa/bbb. ...
-
js 函数function的几种形式
//有的时候我们一直都在使用函数,但是却不知道函数使用的正真含义 //其中一个重要的目的是为了提高代码的复用率 //其二函数可以传递参数并有返回值 //函数声明 //不带参数,不带返回值 functi ...
-
mir9-lua——《热血沙城》45度ARPG手游-Lua移植版
mir9——<热血沙城>,是9秒论坛开源的一个使用Cocos2d-x-2.2.1引擎开发的45度ARPG手游Demo,源代码为c++.mir9-lua是mir9的Lua移植版,使用Quic ...
-
wamp安装注意点!
安装wamp前或者重装系统后,默认没有依赖的组件VC11,需要先安装才能运行 下载地址:http://www.microsoft.com/en-us/download/details.aspx?id= ...
-
团队作业9——Beta版本展示博客
一. 骆杰宁(组长) 风格:少说话,多做事. 擅长技术:Jsp 编程兴趣:GUI 希望角色:PM 一句话宣言:年轻是本钱,不努力就不值钱. 胡丹丹 风格:不断沉淀自己 擅长技术:擅长TCP/IP协议模 ...
-
【我的前端自学之路】【HTML5】.html和.htm的区别
以下为自学笔记内容,仅供参考. 转发请保留原文链接:https://www.cnblogs.com/it-dennis/p/10508171.html .htm 和 .html 的区别 .htm 和 ...
-
在vue中使用highcharts的仪表图等扩展
仪表图(”solidgauge“)在highcharts中属于扩展,单独引入highcharts使用仪表图会报错,需要在你的组件中做一谢其他的引入: // 最主要是这里模块的引入 很坑 import ...