I have searched the forum but can't find any sample code
for storing some text into the clipboard. Ideas?
------------------
for storing some text into the clipboard. Ideas?
------------------
Function SetClipboardText Alias "SetClipboardText" (ByVal sText As String) Export As Long Local hData As Long, hGlob As Long ' ** Create a global memory object and copy the data into it hData = GlobalAlloc(%GMEM_MOVEABLE Or %GMEM_DDESHARE, Len(sText)+1) hGlob = GlobalLock(hData) Poke$ hGlob, sText + Chr$(0) GlobalUnlock hData ' ** Open the clipboard If IsFalse(OpenClipboard(%NULL)) Then GlobalFree hData Exit Function End If ' ** Paste the data into the clipboard EmptyClipboard Function = SetClipboardData(%CF_TEXT, hData) CloseClipboard End Function Function GetClipboardText Alias "GetClipboardText" () Export As String Local zPtr As Asciiz Ptr OpenClipBoard 0 zPtr = GetClipboardData(%CF_TEXT) If zPtr <> 0 Then Function = @zPtr CloseClipboard End Function
#Compile Exe #Dim All #Register None #Include "Win32Api.Inc" CallBack Function DlgProc Static hwndNextViewer As Long, nEvents As Long Local uFormat As Long, Msg As String, TmpAsciiz As Asciiz * %MAX_PATH Select Case CbMsg Case %WM_INITDIALOG hwndNextViewer = SetClipboardViewer(CbHndl) Case %WM_CHANGECBCHAIN If CbWparam = hwndNextViewer Then hwndNextViewer = CbLparam Else _ If hwndNextViewer <> 0 Then SendMessage hwndNextViewer, CbMsg, CbWparam, CbLparam Case %WM_DESTROY ChangeClipboardChain CbHndl, hwndNextViewer Case %WM_DRAWCLIPBOARD If OpenClipboard(CbHndl) Then Incr nEvents Msg = Msg + "Event #" + Format$(nEvents) uFormat = EnumClipboardFormats(0) While uFormat TmpAsciiz = "" GetClipboardFormatName uformat, TmpAsciiz, SizeOf(TmpAsciiz) Msg = Msg + $CRLF + "[" + Format$(uformat) + "] " + TmpAsciiz uFormat = EnumClipboardFormats(uFormat) Wend CloseClipboard End If Control Set Text CbHndl, 101, Msg SendMessage hwndNextViewer, CbMsg, CbWparam, CbLparam End Select End Function Function PbMain Local hDlg As Long Dialog New 0, "List of clipboard formats", ,, 220, 220, %WS_CAPTION Or %WS_SYSMENU, %WS_EX_TOPMOST To hDlg Control Add Label, hDlg, 101, "", 10, 10, 200, 200 Dialog Show Modal hDlg Call DlgProc End Function
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment