展开全部
最简单就是自己写组件
Procedure WMPaste(Var Message: TWMPaste); Message WM_PASTE;
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, clipbrd, StdCtrls;
Type
TForm1 = Class(TForm)
Procedure FormCreate(Sender: TObject);
Private
Public
End;
TMyEdit = Class(TCustomEdit)
Private
Procedure WMPaste(Var Message: TWMPaste); Message WM_PASTE;
Public
Constructor Create(AOwner: TComponent); Override;
Destructor Destroy; Override;
End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}
{ TMyEdit }
Constructor TMyEdit.Create(AOwner: TComponent);
Begin
Inherited;
End;
Destructor TMyEdit.Destroy;
Begin
Inherited;
End;
Procedure TMyEdit.WMPaste(Var Message: TWMPaste);
Var
I: Integer;
S: WideString;
R: WideString;
Begin
//Inherited;
R := '';
S := Trim(clipbrd.Clipboard.AsText);
For I := 1 To Length(S) Do
Begin
If ord(S[I]) In [ord('0')..ord('9'), ord('a')..ord('z'), ord('A')..ord('Z')] Then
Begin
R := R + S[I];
End;
End;
Text := R;
End;
{ TForm1 }
Var
MyEdit: TMyEdit;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
MyEdit := TMyEdit.Create(self);
MyEdit.Parent := Self;
MyEdit.SetBounds(10, 10, 200, 24);
End;
End.
Procedure WMPaste(Var Message: TWMPaste); Message WM_PASTE;
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, clipbrd, StdCtrls;
Type
TForm1 = Class(TForm)
Procedure FormCreate(Sender: TObject);
Private
Public
End;
TMyEdit = Class(TCustomEdit)
Private
Procedure WMPaste(Var Message: TWMPaste); Message WM_PASTE;
Public
Constructor Create(AOwner: TComponent); Override;
Destructor Destroy; Override;
End;
Var
Form1: TForm1;
Implementation
{$R *.dfm}
{ TMyEdit }
Constructor TMyEdit.Create(AOwner: TComponent);
Begin
Inherited;
End;
Destructor TMyEdit.Destroy;
Begin
Inherited;
End;
Procedure TMyEdit.WMPaste(Var Message: TWMPaste);
Var
I: Integer;
S: WideString;
R: WideString;
Begin
//Inherited;
R := '';
S := Trim(clipbrd.Clipboard.AsText);
For I := 1 To Length(S) Do
Begin
If ord(S[I]) In [ord('0')..ord('9'), ord('a')..ord('z'), ord('A')..ord('Z')] Then
Begin
R := R + S[I];
End;
End;
Text := R;
End;
{ TForm1 }
Var
MyEdit: TMyEdit;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
MyEdit := TMyEdit.Create(self);
MyEdit.Parent := Self;
MyEdit.SetBounds(10, 10, 200, 24);
End;
End.
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
BoardHandle:THandle;
BoardStr : PChar;
i : Integer;
Str : string;
begin
if Button = mbright then
begin
Str := '';
OpenClipboard(0);
BoardHandle:=GetClipboardData(CF_TEXT);
BoardStr :=GlobalLock(BoardHandle);
for i := 0 to Length(BoardStr)-1 do
begin
if (BoardStr[i] in ['A'..'Z'])
or (BoardStr[i] in ['a'..'z'])
or (BoardStr[i] in ['0'..'9']) then
begin
Str := Str + BoardStr[i];
end;
end;
CloseClipboard;
Edit1.Text := Str;
end;
end;
Shift: TShiftState; X, Y: Integer);
var
BoardHandle:THandle;
BoardStr : PChar;
i : Integer;
Str : string;
begin
if Button = mbright then
begin
Str := '';
OpenClipboard(0);
BoardHandle:=GetClipboardData(CF_TEXT);
BoardStr :=GlobalLock(BoardHandle);
for i := 0 to Length(BoardStr)-1 do
begin
if (BoardStr[i] in ['A'..'Z'])
or (BoardStr[i] in ['a'..'z'])
or (BoardStr[i] in ['0'..'9']) then
begin
Str := Str + BoardStr[i];
end;
end;
CloseClipboard;
Edit1.Text := Str;
end;
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询