Hooking the windows clipboard?
Hooking the windows clipboard?
Has anyone done any work with regards to hooking the windows clipboard (and willing to share)?
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Hooking the windows clipboard?
Personally, I've never done it but if I were to need it at some point, I think I'd start here: http://www.delphidabbler.com/articles?article=9
BERESHEIT
Re: Hooking the windows clipboard?
Yes it is straight forward enough; registering one of your windows as a clipboard viewer. I am not on my development machine right now so cannot yank out any code, but once you have registered your window you just have to look out for and respond to a couple of Windows messages, checking the available clipboard formats as and when appropriate.
I may look like a mule, but I'm not a complete ass.
Re: Hooking the windows clipboard?
Thank you! That's helpful -- much easier reading than examples I found.
Thanks srod, for the info.
-j
Thanks srod, for the info.
-j
Re: Hooking the windows clipboard?
This might be a start
might also see EnumClipboardFormats_
and IsClipboardFormatAvailable_
There are some complete examples in the forums, I believe, but this may get you started.
cheers
Code: Select all
nextviewer=SetClipboardViewer_(WindowID(#window_0)) ; So we are informed of clipboard changes.
SetWindowCallback(@windowCallback())
; in windows callback
Case #WM_DRAWCLIPBOARD
;process the TEXT format
If OpenClipboard_(0)
If IsClipboardFormatAvailable_(#CF_TEXT) <> 0
hStrPtr.l = GetClipboardData_(#CF_TEXT)
If hStrPtr
text$= PeekS(hStrPtr)
endif
endif
;other formats?
endif
CloseClipboard_()
SendMessage_(nextviewer,message,wParam,lParam); free the clipboard
ProcedureReturn Resultand IsClipboardFormatAvailable_
There are some complete examples in the forums, I believe, but this may get you started.
cheers
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Hooking the windows clipboard?
Hooking never worked for me on some PCs I used at work, so I gave up relying on it. Just a warning. Setting a clipboard viewer and then forwarding the messages on is not going to work on all PCs, trust me. I ended up just using my own clipboard monitoring routine instead.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
- utopiomania
- Addict

- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Re: Hooking the windows clipboard?
I had the same question. Thanks, rsts!