welcome to PB.
The problem is definitely not on the PB side.
If you want check it by yourself, you can use the small test app I put together as a proof of concept
Code: Select all
; -----------------------------------------------------------------------------
; ClipBoard Handling
; -----------------------------------------------------------------------------
EnableExplicit
DebugLevel 9
#Caption = "Example of Clipboard "
#TimerID = 1
Enumeration EWindow 1
#WndMain
EndEnumeration
Enumeration EGadget 1
#ChkDirectUpdate
#ChkWatchClipboard
#StrText
#StrHex
EndEnumeration
; -----------------------------------------------------------------------------
Define s_hNextClipboardListener = 0
; -----------------------------------------------------------------------------
Procedure ClipboardListener(Window, State)
Shared s_hNextClipboardListener
Select State
Case 0
If s_hNextClipboardListener <> 0 :Debug #PB_Compiler_Procedure + "() --> exit ", 9
ChangeClipboardChain_(WindowID(Window), s_hNextClipboardListener)
s_hNextClipboardListener = 0
EndIf
Case 1
If s_hNextClipboardListener = 0 :Debug #PB_Compiler_Procedure + "() --> init ", 9
; so, now we are informed of clipboard changes
s_hNextClipboardListener = SetClipboardViewer_(WindowID(Window))
EndIf
EndSelect
;ProcedureReturn State
EndProcedure
; -----------------------------------------------------------------------------
Procedure.s TextToHex(Text.s)
Protected result.s, n, txlen , cnt
If Text <> ""
txlen = Len(Text)
result = ""
For n = 1 To txlen
result + RSet(Hex(Asc(Mid(Text, n, 1))), 4, "0") + " "
cnt + 1
If cnt >= 16
result + #CRLF$
cnt = 0
EndIf
Next
EndIf
ProcedureReturn result
EndProcedure ;()
; -----------------------------------------------------------------------------
Procedure MainWindow_OnCallBack(hWnd, uMsg, wParam, lParam)
Shared s_hNextClipboardListener
Protected result = #PB_ProcessPureBasicEvents
Protected txt.s, t.s
Select uMsg
Case #WM_CHANGECBCHAIN :Debug "#WM_CHANGECBCHAIN", 9
If wParam = s_hNextClipboardListener
s_hNextClipboardListener = lParam
ElseIf s_hNextClipboardListener <> 0
SendMessage_(s_hNextClipboardListener, uMsg, wParam, lParam)
EndIf
result = 1
Case #WM_DRAWCLIPBOARD :Debug "#WM_DRAWCLIPBOARD", 9
txt = GetClipboardText() ; Show new content
SetGadgetText(#StrText, txt)
SetGadgetText(#StrHex, TextToHex(txt))
SendMessage_(s_hNextClipboardListener, uMsg, wParam, lParam)
result = 1
EndSelect
ProcedureReturn result
EndProcedure
; -----------------------------------------------------------------------------
Procedure OnEventSizeWindow()
Protected wndW, wndH
wndW = WindowWidth(#WndMain)
wndH = WindowHeight(#WndMain) - 32
wndH / 2
ResizeGadget(#StrText, #PB_Ignore, #PB_Ignore, wndW, wndH-2)
ResizeGadget(#StrHex, #PB_Ignore, wndH+34, wndW, wndH-2)
EndProcedure
Procedure main()
Protected quitLoop, wndW, wndH, flags
Protected hFont
Protected counter
hFont = FontID(LoadFont(#PB_Any, "Consolas", 8))
flags = #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_Invisible
wndW = 640 : wndH = 320
If OpenWindow(#WndMain, 200, 200, wndW, wndH, #Caption, flags)
CheckBoxGadget(#ChkDirectUpdate, 208, 8, 160, 18, "Direct Update")
CheckBoxGadget(#ChkWatchClipboard, 8, 8, 160, 20, "Watch Clipboard")
wndH - 32
wndH / 2
flags = #ES_MULTILINE | #ES_AUTOVSCROLL | #WS_VSCROLL | #WS_HSCROLL |
;#PB_String_BorderLess |
;#PB_String_ReadOnly |
0
StringGadget(#StrText, 0, 32, wndW, wndH-2, "", flags)
SetGadgetFont(#StrText, hFont)
StringGadget(#StrHex, 0, wndH + 34, 640, wndH-2, "", flags)
SetGadgetFont(#StrHex, hFont)
BindEvent(#PB_Event_SizeWindow, @OnEventSizeWindow(), #WndMain)
SetWindowCallback(@MainWindow_OnCallBack(), #WndMain)
HideWindow(#WndMain, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
counter + 1
SetClipboardText("Space Space . counting = " + counter)
Beep_(80, 80)
Case #PB_Event_CloseWindow
quitLoop = #True
Case #PB_Event_Gadget
Select EventGadget()
Case #ChkDirectUpdate
If GetGadgetState(#ChkDirectUpdate)
counter = 0
AddWindowTimer(#WndMain, 1, 1000)
Else
RemoveWindowTimer(#WndMain, 1)
EndIf
Case #ChkWatchClipboard
ClipboardListener(#WndMain, GetGadgetState(#ChkWatchClipboard))
EndSelect
EndSelect
Until quitLoop
EndIf
ProcedureReturn 0
EndProcedure
End main()