PowerBuilder – Clearing the clipboard
Powerbuilder’s native ‘clipboard’ method does not clear out the buffer. Here is how to do it:
// external function declarations Function boolean OpenClipboard ( & ulong hWndNewOwner & ) Library "user32.dll" Function boolean EmptyClipboard ( & ) Library "user32.dll" Function boolean CloseClipboard ( & ) Library "user32.dll" // code in application PowerObject lpo_parent ULong lul_hWnd // loop thru parents until a window is found lpo_parent = This.GetParent() Do While lpo_parent.TypeOf() <> Window! and IsValid (lpo_parent) lpo_parent = lpo_parent.GetParent() Loop // get handle to window lul_hWnd = Handle(lpo_parent) // clear the clipboard If OpenClipboard(lul_hWnd) Then EmptyClipboard() CloseClipboard() Else // something else has the clipboard locked. MessageBox("error","OpenClipboard Failed") End If
Updated March 2021 – not tested with newer PowerBuilder or Windows versions