15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


A problem with CallNextHookEx

Andrea Bioli -- abioli@mbox.vol.it
Wednesday, January 29, 1997

Environment: Win95, VC++ 4.2b

Hi,

I would like to handle the event of copying text data into the clipboard.

I can write a keyboard hook handler that gets Ctrl-Ins combination, and
I thought I could get the just copied text calling first CallNextHookEx
to let the system make the copy, and then opening clipboard, asking for
the CF_TEXT format and so on.

What happens is that I can only get 'sometimes' the text 'before' the
copy, 'sometimes' because I cannot debug the hook function and I just
don't really know what's going on (I only know sometimes I don't get
anything back).

I think this has something to do with the OLE implementation of the
clipboard, so even if I call first CallNextHookEx, the operation is still
not ended when I ask for the text in the clipboard. I also thought
I couldn't open the clipboard in this case (because someone else is
owing it), but it doesn't look to care a lot about it.

I hope in some help by somebody who has already done something in this
area.

Thanks in advance.

Andrea Bioli
abioli@mbox.vol.it




Lee Thompson -- lee@mail1.nai.net
Friday, January 31, 1997

[Mini-digest: 2 responses]

Hi,

If all you are looking to do is track and/or get a copy of anything
paced in the clipboard, you can insert your app into the Clipboard View
chain that gets notified whenever the contents of the clipboard change.
That way you don't have to mess with keyboard hooks which won't work
anyway under certain circumstances, like pressing a copy toolbar button.


Lee
-----From: ybriklin@juno.com (Yuriy Briklin)

Hi Andrea.

You may use CWnd::SetClipboardViewer( ) to register your window as a
clipboard viewer. 
This adds a  window to the chain of windows that are notified (by means
of the WM_DRAWCLIPBOARD message) whenever the content of the Clipboard is
changed. Then you can get new clipboard data and do whatever you want.

Yuriy Briklin
e-mail: ybriklin@juno.com


On Wed, 29 Jan 1997 12:46:20 +0100 "Andrea Bioli" 
writes:
> Environment: Win95, VC++ 4.2b
> 
> Hi,
> 
> I would like to handle the event of copying text data into the 
> clipboard.
> 
> I can write a keyboard hook handler that gets Ctrl-Ins combination, 
> and
> I thought I could get the just copied text calling first 
> CallNextHookEx
> to let the system make the copy, and then opening clipboard, asking 
> for
> the CF_TEXT format and so on.
> 
> What happens is that I can only get 'sometimes' the text 'before' the
> copy, 'sometimes' because I cannot debug the hook function and I just
> don't really know what's going on (I only know sometimes I don't get
> anything back).
> 
> I think this has something to do with the OLE implementation of the
> clipboard, so even if I call first CallNextHookEx, the operation is 
> still
> not ended when I ask for the text in the clipboard. I also thought
> I couldn't open the clipboard in this case (because someone else is
> owing it), but it doesn't look to care a lot about it.
> 
> I hope in some help by somebody who has already done something in 
> this
> area.
> 
> Thanks in advance.
> 
> Andrea Bioli
> abioli@mbox.vol.it
> 
> 




| Вернуться в корень Архива |