Board index » delphi » Intercept windows past messages

Intercept windows past messages

Hi all,

I want to implement an OnPast message. Can someone tell me if there is a
better way to intercept the paste messages to an edit component?. I've tried
WndProc, WMPaste and DefaultHandle non of which seam to receive the
WM_PASTE.

What haven't I done yet?

Okorie

 

Re:Intercept windows past messages


Okorie -

For a standard edit control, all you should have to do is use a
WM_PASTE message handler:

type
  TMyEdit = class(TEdit)
  procedure WMPaste(var Msg: TWMPaste); message WM_Paste;
  end;

procedure TMyEdit.WMPaste(var Msg: TWMPaste);
begin
  inherited;  // Do your stuff here
end;

Note that if the clipboard is empty, this won't get invoked.
Good luck.

Kurt

Re:Intercept windows past messages


Quote
In article <8v8led$p...@bornews.inprise.com>, Okorie wrote:
> I want to implement an OnPast message. Can someone tell me if there is a
> better way to intercept the paste messages to an edit component?. I've tried
> WndProc, WMPaste and DefaultHandle non of which seam to receive the
> WM_PASTE.

A TEdit descendent will see WM_PASTE messages send to it in a message handler
for it. But if the user presses Ctrl-V in the control that may not send this
message. It would be the logical thing to do to implement paste in a central
location, but we are talking about a MS control here and they are prone to
take shortcuts. So you may have to trap the key combination as well as
WM_PASTE.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Intercept windows past messages


That makes sense, I always use the Ctrl+V and nothing (WM_PASTE) happens.
Maybe I should rewrite TMemo for my particular needs.
Thanks

Other Threads