Date: 02-16-2022
Return to Index
created by gbSnippets
'Credit: Borje Hagsten
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
%IDC_Label = 500
Global hDlg,hNextViewer As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Clipboard Monitor",300,300,400,200, %WS_OverlappedWindow To hDlg
Control Add Label,hDlg, %IDC_Label, "<clipboard content>",0,0,400,200
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
Select Case CbMsg
Case %WM_InitDialog
hNextViewer = SetClipboardViewer(hDlg) ' add ourselves to the chain of clipboard viewers
Case %WM_CHANGECBCHAIN ' clipboard viewer chain has changed
If Cb.WParam = hNextViewer Then
hNextViewer = Cb.LParam
Else
If hNextViewer Then SendMessage hNextViewer, Cb.Msg, Cb.WParam, Cb.LParam
End If
Case %WM_DRAWCLIPBOARD ' clipboard content has changed
Clipboard Get Text To temp$
If Len(temp$) Then Control Set Text hDlg, %IDC_Label, temp$
If hNextViewer Then SendMessage hNextViewer, Cb.Msg, Cb.WParam, Cb.LParam : Function = 1
Case %WM_Destroy
If hNextViewer Then ChangeClipboardChain hDlg, hNextViewer 'remove app from clipboard viewer chain
End Select
End Function
'gbs_01219
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm