Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I found this statement about WM_PASTE function in MSDN and I am a little bit confused about it

Quote:
An application sends a WM_PASTE message to an edit control or combo box to copy the current content of the clipboard to the edit control at the current caret position. Data is inserted only if the clipboard contains data in CF_TEXT format.


What does it mean by "edit control" or "combo box"? Can I use WM_Paste message to detect paste event happening in the Windows environment?

What I have tried:

C#
protected override void WndProc(ref Message m)
 {
             
    base.WndProc(ref m);
    if(m.Msg == WM_PASTE)
      {
         string message= "Paste";
      }

}


But this message doesn't show when I paste (Ctrl + v, Edit > paste, Shell context menu paste) a text on an application (example: Notepad). I want to know what is the purpose of this WM_Paste message and how to detect it when I paste something.
Posted
Updated 15-Jul-18 21:33pm
Comments
Richard MacCutchan 16-Jul-18 8:22am    
Thanks to Jochen for noticing that we have already explained this to you more than once.

Read the description again: “an application sends ...”. That means that your application can send this message to a control in order to let the control know that there is data on the clipboard. The message is not a general notification that you can capture.
 
Share this answer
 
The WM_PASTE message is an application internal message. It might be send for example to the active control window when choosing the Paste option from the Edit menu of an application, the context menu of a control window, or upon the Ctrl-V / Shift-Ins accelerators.

Besides a few execpetions, messages are handled on application level. They are send to a specific window which might forward them to the parent window or child windows. But such application level messages are not forwarded to windows of other applications.

Your code example is catching the message in your application. That is not called when pasting in any other application.

It has been all said at your previous question How to capture the paste event in windows?[^]:
There is no general and reliable method to catch paste events outside your application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900