Home > Back-end >  Delphi as bao ban the text frame's copy and paste!!!!!
Delphi as bao ban the text frame's copy and paste!!!!!

Time:09-30

As title, which explain, appreciate!!!!!!

CodePudding user response:

1. Check if keys Ctrl + C/Ctrl + V
2. Disable the text box of the right mouse button

CodePudding user response:

Create a new project, put a text box, then add the following code red:
The unit Unit1;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

Type
TEdit=class (StdCtrls TEdit)
Procedure WndProc (var Message: TMessage); Override.
end;

TForm1=class (TForm)
Edit1: TEdit;
Private
{Private declarations}
Public
{Public declarations}
end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

{TEdit}

procedure TEdit. WndProc (var Message: TMessage);
The begin
With the Message do
If (Msg=WM_COPY) or (Msg=WM_CUT) or (Msg=WM_PASTE) then
The Exit;
Inherited
end;


The end.

CodePudding user response:

Record for use

CodePudding user response:

Record for use

CodePudding user response:

This is very good, I used the message mechanism,

CodePudding user response:

Should also join the keyboard message, otherwise the somebody else press CTRL + C can also, ha ha,

CodePudding user response:

The text box is set to enabled:=false

CodePudding user response:

Delete text box, or put the text box set to invisible
Visible:=false;
Hey hey hey hey

CodePudding user response:

If it is disable all TEdit control, use the method of the second floor
If specific TEdit control is disabled, you can use below method

 unit Unit11; 

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables;

Type
TForm11=class (TForm)
Edt1: TEdit;
Qry1: TQuery;
Edt2: TEdit;
Procedure FormCreate (Sender: TObject);
Procedure FormDestroy (Sender: TObject);
Procedure edt1ContextPopup (Sender: TObject; MousePos: TPoint;
Var Handled: Boolean);
Private
{Private declarations}
FOldWndProc: TWndMethod;//save the particular control the original address
Public
{Public declarations}
Procedure NewWndProc (var Message: TMessage);//the new message definition
end;

Var
Form11: TForm11;

Implementation

{$R *. DFM}
Procedure TForm11. NewWndProc (var Message: TMessage);
The begin
//copy, cut and paste
If (Message. Msg=WM_CUT) or (Message. Msg=WM_COPY) or
(Message. Msg=WM_PASTE)
Then
exit;

FOldWndProc (Message);
end;

Procedure TForm11. Edt1ContextPopup (Sender: TObject; MousePos: TPoint;
Var Handled: Boolean);
The begin
Handled:=True;//disable the right-click menu
end;

Procedure TForm11. FormCreate (Sender: TObject);
The begin
FOldWndProc:=edt1. WindowProc;
Edt1. WindowProc:=NewWndProc;
end;

Procedure TForm11. FormDestroy (Sender: TObject);
The begin
Edt1. WindowProc:=FOldWndProc;
end;

End.

CodePudding user response:

The second floor is intercepted messages directly, should even stop button off,,

CodePudding user response:

Focus on pick up clear clipboard text box

CodePudding user response:

Learning,,,,,,,

CodePudding user response:

Feel the ninth floor to try tomorrow

CodePudding user response:



Early in the morning to see technical post, the collection

CodePudding user response:

refer to 7th floor sz_haitao response:
set text box to enabled:=false


Simple and direct way

CodePudding user response:


 
Private
{Private declarations}
PressCtrl: Boolean;



Procedure TForm1. Edit1KeyDown (Sender: TObject; Var Key Word;
Shift: TShiftState);
The begin
If the Shift=[ssCtrl] then
The begin
PressCtrl:=True;
end;
end;

Procedure TForm1. Edit1KeyPress (Sender: TObject; Var Key: Char);
The begin
If PressCtrl then
The begin
If (Key=# 22) then
The begin
Key:=# 0;
PressCtrl:=False;
end;
end;
end;

CodePudding user response:

Banned text box right click on the word
Add a TPopupMenu to form set PopupMenu text box for the new popup menu

CodePudding user response:

reference 16 floor gykthh response:
Delphi/Pascal code? 1234567891011121314151617181920212223242526 private {private declarations} PressCtrl: Boolean; Procedure TForm1. Edit1KeyDown (Sender: TObject; Var Key Word; Shift: TShif...


Modify the following more easily understand
 
Procedure TForm1. Edit1KeyDown (Sender: TObject; Var Key Word;
Shift: TShiftState);
The begin
If the Shift=[ssCtrl] then
The begin
If (Key=word (' C ')) or (Key=word (' V ')) or (Key=word (' X ')) then
PressCtrl:=True; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related