Trapping for the Pasting from within a Windows Application such as Excel, for Example

T

TC

Hello All,

I know similar questions have been asked before but I haven't found any good
answers.

I know I can use a hook to trap for Ctrl-V on keyboard.

I know that I can use WM_PASTE to trap for a paste from within a textbox
control (i.e. userform trapping).

I am wondering if there is a singular to trap for ALL pasting from within a
Windows application (i.e. Ctrl-V, Edit>Paste, pasting from the Office Suite
Clipboard, etc.)? Is there ultimately a singular notification or message
that one can use to trap for ALL circumstances?

If so, do the same APIs and structures and interfaces expose themselves to
VB or can it be translated to VB without the use of 3rd party tools or
libraries?

Best Regards,

Todd
 
W

William DePalo [MVP VC++]

TC said:
I am wondering if there is a singular to trap for ALL pasting from within
a Windows application (i.e. Ctrl-V, Edit>Paste, pasting from the Office
Suite Clipboard, etc.)? Is there ultimately a singular notification or
message that one can use to trap for ALL circumstances?

You can read the article "Creating a Clipboard Viewer Window" here:

http://msdn.microsoft.com/library/d...rue#_win32_Creating_a_Clipboard_Viewer_Window

which explains how to create a window that receives a notification evertime
the clipboard is changed.

Regards,
Will
 
I

Igor Tandetnik

TC said:
I am wondering if there is a singular to trap for ALL pasting from
within a Windows application (i.e. Ctrl-V, Edit>Paste, pasting from
the Office Suite Clipboard, etc.)? Is there ultimately a singular
notification or message that one can use to trap for ALL
circumstances?

No. An application is free to implement Paste command any way it wants,
there is no "standard" way. Using WM_PASTE message is pretty common, but
by no means mandatory.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage
 
T

TC

Hey William,

Thanks for the info.

I am trying to create something from within VB and was wondering if you new
what the constant would be for IDM_PASTE represented as a long?

Regards,

Todd
 
T

TC

Hey Igor,

Thanks for the information.

So I guess the only way would be to check for WM_PASTE or IDM_PASTE and hope
that these are implemented or continue to try and trap for various messages
until one unscrambles the message sequence for the various pasting methods
of a particular application, yes?

Regards,

Todd




Igor Tandetnik said:
TC said:
I am wondering if there is a singular to trap for ALL pasting from
within a Windows application (i.e. Ctrl-V, Edit>Paste, pasting from
the Office Suite Clipboard, etc.)? Is there ultimately a singular
notification or message that one can use to trap for ALL
circumstances?

No. An application is free to implement Paste command any way it wants,
there is no "standard" way. Using WM_PASTE message is pretty common, but
by no means mandatory.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles Babbage
 
I

Igor Tandetnik

TC said:
I am trying to create something from within VB and was wondering if
you new what the constant would be for IDM_PASTE represented as a
long?

26
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage
 
A

alpine

Hello All,

I know similar questions have been asked before but I haven't found any good
answers.

I know I can use a hook to trap for Ctrl-V on keyboard.

I know that I can use WM_PASTE to trap for a paste from within a textbox
control (i.e. userform trapping).

I am wondering if there is a singular to trap for ALL pasting from within a
Windows application (i.e. Ctrl-V, Edit>Paste, pasting from the Office Suite
Clipboard, etc.)? Is there ultimately a singular notification or message
that one can use to trap for ALL circumstances?

If so, do the same APIs and structures and interfaces expose themselves to
VB or can it be translated to VB without the use of 3rd party tools or
libraries?

Best Regards,

Todd


Jeeeezzzz! Do you think you have crossposted enough groups there?
Maybe you should add a couple more just for good measure! ;-)

You might want to have a look at the No Clipboard example at
http://www.mvps.org/vbvision

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don'(e-mail address removed) Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don'(e-mail address removed) Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
 
W

William DePalo [MVP VC++]

TC said:
Thanks for the info.

You are welcome. But maybe you shouldn't thank me. :)

I read your post quickly and just assumed you wanted to ne notified of
things _copied to_ the clipboard. That's easy. But as Igor points out it is
far more difficult to be able to tell when applications about which you have
no knowledge will copy the data there.

Regards,
Will
 
R

Richard Jalbert

TC said:
I am wondering if there is a singular to trap for ALL pasting from
within a Windows application (i.e. Ctrl-V, Edit>Paste, pasting from
the Office Suite Clipboard, etc.)? Is there ultimately a singular
notification or message that one can use to trap for ALL
circumstances?

No. An application is free to implement Paste command any way it wants,
there is no "standard" way. Using WM_PASTE message is pretty common, but
by no means mandatory.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage

Plus some VB controls (like RichTextBox) implement their own paste
that intercept the CTRL_V keys before you can programmaticaly get it.
With the result that an action is performed twice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top