Reputation: 377
I have my application running under VirtualUI. Because is creates a remote session, there is an issue with clipboard values being stored sometimes in Server's Clipboard and the other time in Client's Clipboard.
Behavior depends on the way user copy/paste: - Ctrl+C/V works because VirtualUI is able to capture keyboard events but; - right click + Copy/Paste does not work, environment is not able to capture the event properly and values are stored in wrong Clipboards resulting in some cases different values being copied and different being paste (if a user uses right clisc + Copy and then Ctrl + V - or the other way)
Is there a way to disable or hide Copy and Paste items on a default popup menu that comes with TEdit right click?
So far we have contacted VirtualUI developers and they confirmed the issue exists but there is nothing they can do about it. This is where we came up with this idea of hiding Copy/Paste items on default popup menu of all controls.
There is no code yet as we don't even know if it is possible
The desired solutions would be a default TEdit (or any other control) popupmenu, without Copy and Paste items.
Upvotes: 1
Views: 990
Reputation:
The best solution i found so far is to create a new class that inherits from TEdit and filter the "WM_COPY" and "WM_CUT" messages in the DefaultMessage procedure:
type
TMyEdit = class(TEdit)
public
procedure DefaultHandler(var Message); override;
end;
procedure TMyEdit.DefaultHandler(var Message);
begin
case TMessage(Message).Msg of
WM_COPY, WM_CUT: begin
// insert code here
end;
else inherited DefaultHandler(Message);
end;
end;
this way the copy/paste items dont disapear from the popupmenu but they dont do anything anymore. If you want to notify the user of this you can insert your own code.
Also here I found a procedure that would help change the ClassType of the TEdit´s more easily. Just call the procedure in OnCreate and you should be fine:
procedure EditToMyEdit(edt: TEdit);
type
PClass = ^TClass;
begin
if Assigned(edt) then
PClass(edt)^ := TMyEdit;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
EditToMyEdit( Edit1 );
end;
Hope I could help.
Upvotes: 1