How to unlock the Clipboard when another app misbehaves
Posted: Fri Sep 22, 2006 9:28 pm
Hi all
I'm having a problem. Something in my PC (and I know it's not FWH) is not releasing the Windows Clipboard, forcing me to reboot my PC in order to be able to do the everyday Cut & Paste stuff!
Researching in msdn, I found a couple of API functions that I thought would allow me to forcibly kill the other apps stronghold on the clipboard, but I'm missing something.
doing something like
Has no efect.
If anyone has already created a routine that can release the clipboard when a misbehaved app doesn't release it, I'd appreciate your help.
Regard,
Luis
I'm having a problem. Something in my PC (and I know it's not FWH) is not releasing the Windows Clipboard, forcing me to reboot my PC in order to be able to do the everyday Cut & Paste stuff!
Researching in msdn, I found a couple of API functions that I thought would allow me to forcibly kill the other apps stronghold on the clipboard, but I'm missing something.
Code: Select all
DLL32 FUNCTION ClipboardOwner() ;
AS LONG PASCAL FROM "GetClipboardOwner" Lib "user32"
DLL32 FUNCTION ClipboardChain( ;
hPrevWnd AS LONG, ;
hNewWnd AS LONG ) ;
AS LONG PASCAL FROM "ChangeClipboardChain" Lib "user32"
Code: Select all
#define WM_DESTROYCLIPBOARD 775
Function Test()
Local oClp
Local hOwner := 0
Local hNewOwner := 0
MsgInfo( ClipBoardOwner() )
oClp := TClipboard():New()
//MsgInfo( "App handle: " + cValToChar( oClp:oWnd:hWnd ) )
oClp:Open()
// this doesn't forcibly release ownership
hOwner := ClipBoardOwner()
MsgGet( "New Clipboard Owner Handle", "New ::hWnd:", @hNewOwner )
ClipboardChain( hOwner, hNewOwner )
SendMessage( hNewOwner, WM_DESTROYCLIPBOARD, 0, 0 )
oClp:Close() // this works as expected, of course
hOwner := ClipBoardOwner()
MsgInfo( "Clipboard Owner: " + cValToChar( hOwner ) )
return nil
If anyone has already created a routine that can release the clipboard when a misbehaved app doesn't release it, I'd appreciate your help.
Regard,
Luis