In the code below
I added a RemoveClipboardFormatListener
and a GetClipboardText() .
The program runs fine with or without RemoveClipboardFormatListener .
Is it good programming to use it ?
Also , is it good programming to use GetClipnoardText()
with AddClipboardFormatListener . (oranges & apples)
It works great , but just wanted to check ?
Thanks
Code: Select all
; By netmaestro July 2016
; Demo monitoring clipboard changes
;
Global getStrText$
#WM_CLIPBOARDUPDATE = $031D
Declare Winproc(hwnd, msg, wParam, lParam)
OpenLibrary(0, "user32.dll")
Prototype AddClipboardFormatListener(hwnd)
Prototype RemoveClipboardFormatListener(hwnd)
Global AddClipboardFormatListener_.AddClipboardFormatListener = GetFunction(0, "AddClipboardFormatListener")
Global RemoveClipboardFormatListener_.RemoveClipboardFormatListener = GetFunction(0, "RemoveClipboardFormatListener")
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ListViewGadget(0,10,10,200,200)
SetWindowCallback(@WinProc())
StickyWindow(0,1)
AddClipboardFormatListener_(WindowID(0))
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
RemoveClipboardFormatListener_(WindowID(0))
CloseLibrary(0)
;---------------------------------------------
; End of Main Loop Code
;---------------------------------------------
Procedure WinProc(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CLIPBOARDUPDATE
getStrText$ = GetClipboardText()
AddGadgetItem(0, -1, getStrText$)
EndSelect
ProcedureReturn result
EndProcedure
Quote tags>Code tags
28.09.2016
RSBasic