There are many options, for example
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if (Key=#22) or (Key=#3) then Key:=#0; // 22 = [Ctrl+V] / 3 = [Ctrl+C] end;
option number 2 ( original )
... var Form1: TForm1; NextInChain : THandle; implementation uses ClipBrd; ... procedure WMDrawClipboard(var Msg: TMessage) ; message WM_DRAWCLIPBOARD; procedure WMChangeCBChain(var Msg: TMessage) ; message WM_CHANGECBCHAIN; ... procedure TForm1.WMDrawClipboard(var Msg:TMessage) ; begin if Clipboard.HasFormat(cf_text) then begin Memo1.Lines.Clear; Memo1.PasteFromClipboard end else begin // работа других форматов end; //pass the message on to the next window if NextInChain <> 0 then SendMessage(NextInChain, WM_DrawClipboard, 0, 0) end; procedure TForm1.WMChangeCBChain(var Msg: TMessage) ; var Remove, Next: THandle; begin Remove := Msg.WParam; Next := Msg.LParam; with Msg do if NextInChain = Remove then NextInChain := Next else if NextInChain <> 0 then SendMessage(NextInChain, WM_ChangeCBChain, Remove, Next) end; ... procedure TForm1.FormCreate(Sender: TObject) ; begin NextInChain := SetClipboardViewer(Handle) ; end;
WM_COPY
used forPlain text
. Perhaps it is easier to disable text selection in (for example)OnSelectionChange
? - kamiOnSelectionChange
not a very good option, since the user can select and delete selected text, for example. it is allowed but not copied - gregor