Memo控件怎样防止拷贝?

netsys 2006-02-16 02:54:14

Memo里写了一些东西,要求不能通过键盘、鼠标选择后拷贝其中的文字。
...全文
124 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
netsys2 2006-02-16
  • 打赏
  • 举报
回复
谢谢两位,各50分!
lurel 2006-02-16
  • 打赏
  • 举报
回复
让老妖抢先了
下面是我写的
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TWndMethod oldWndProc;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{

oldWndProc=Memo1->WindowProc;
Memo1->WindowProc=newWndProc;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::newWndProc(TMessage &message)
{
switch(message.Msg)
{
case WM_GETTEXT:
return;
case WM_COPY:
return;
}
//TForm1::WndProc(message);
oldWndProc(message);
}

ccrun.com 2006-02-16
  • 打赏
  • 举报
回复
没有现成的,只好现写一个:

.h文件:
private: // User declarations
void __fastcall NewProc(TMessage &Message);

.cpp文件:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Memo1->WindowProc = NewProc;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NewProc(TMessage &Msg)
{
if(Msg.Msg == WM_GETTEXT || Msg.Msg == WM_COPY)
{
Msg.Result = 1;
return;
}
else
Memo1->Dispatch(&Msg);
}
netsys2 2006-02-16
  • 打赏
  • 举报
回复
有没有现成的代码?
ccrun.com 2006-02-16
  • 打赏
  • 举报
回复
严格的来处理,应该是截获WM_GETTEXT和WM_COPY消息。
lurel 2006-02-16
  • 打赏
  • 举报
回复
截获WM_COPY,然后return

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧