Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: AndreasG am 08.07.03 - 09:28:06
-
Hallo, ich würde gerne Text aus einem Dokument in die
Zwischenablage kopieren.
Bisher mache ich das so:
Sub Click(Source As Button)
Dim wks As New NotesUIworkspace
clipboardstring=""
Set uidoc = wks.CurrentDocument
uidoc.EditMode = True
Set doc = uidoc.Document
Call uidoc.GotoField( "cbf1" )
Call uidoc.SelectAll
Call uidoc.Copy
End Sub
Ich würde gerne wissen ob es auch möglich ist, DIREKT
den Inhalt einer stringvariablen ins clipboard zu kopieren.
Und nicht erst das Dokument zum editieren aufzurufen und
den Feldinhalt zu markieren.
-
Hi,
hier der Code..(das Thema war vor ein paar Tagen schonmal da.. :) )
This function calls Win32 functions to put a field or text in the clipboard:
This goes in (Options):
'dataformat ID for ANSI text with ending null (\0). CR(13)/ LF(10) are for end of line.
Public Const CF_TEXT = &H001
This goes in (Declarations):
Declare Function OpenClipboard Lib "User32.dll" Alias "OpenClipboard" (Byval hWnd As Long) As Long
Declare Function EmptyClipboard Lib "User32.dll" Alias "EmptyClipboard" ( ) As Long
Declare Function SetClipboardData Lib "User32.dll" Alias "SetClipboardData" (Byval wFormat As Integer,Byval hAnsiText As Long ) As String
Declare Function GetClipboardData Lib "User32.dll" Alias "GetClipboardData" (Byval wFormat As Integer) As String
Declare Function CloseClipboard Lib "User32.dll" Alias "CloseClipboard" ( ) As Long
Declare Function MYlstrcpy Lib "Kernel32.dll" Alias "lstrcpyA" (Byval Buffer As Long, Byval COPYString As String) As Long
Declare Function GlobalAlloc Lib "Kernel32.dll" Alias "GlobalAlloc" (Byval wFlags As Long, Byval dwBytes As Long) As Long
Declare Function GlobalLock Lib "Kernel32.dll" Alias "GlobalLock"(Byval hMem As Long) As Long
Declare Function GlobalUnlock Lib "Kernel32.dll" Alias "GlobalUnlock" (Byval hMem As Long) As Long
Declare Function GlobalFree Lib "Kernel32.dll" Alias "GlobalFree" (Byval hMem As Long) As Long
This goes in the Click event for a button:
Sub Click(Source As Button)
Dim Status As Long
Dim ptr As Long, ghand As Long,handle As Long
Dim Text As String
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim item As NotesItem
Dim session As New notessession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As notesDocument
Set db = session.currentdatabase
Set col = db.unprocesseddocuments
Set doc = col.getfirstdocument
' Control of platform 16/32-Bit
If Instr(session.platform,"16") Then
Messagebox ("Wrong Windows-platform; this agent runs only under Windows NT/95")
Exit Sub
End If
' Select Notes field
Set item = doc.GetFirstItem("xxxxxx")
' open clipboard
Status = OpenClipboard(handle)
If Status <> 0 Then
' Example: reading clipboard contense
'Text = GetClipboardData(CF_TEXT)
'Delete clipboard contense
Status = EmptyClipboard()
' for testing purpose make a textstring
'Text = "Manfred Doerwald"
'get global storage for field contense
ghand = GlobalAlloc(0,(Len(item.Values(0))+1))
'or global storage for textstring contense
'ghand = GlobalAlloc(0,(Len(Text)+1))
'lock global storage
ptr = GlobalLock(ghand)
'copy contense of field to global storage
Status = MYlstrcpy(ptr,item.Values(0))
'or copy of textstring contense
'Status = MYlstrcpy(ptr,Text)
'free global storage
Status = GlobalUnlock(ghand)
'write to clipboard
Call SetClipboardData(CF_TEXT, ptr)
'close clipboard
Status = CloseClipboard()
'free handle of global storage
Status = GlobalFree(ghand)
Else
Messagebox ("Error opening the clipboard!")
Exit Sub
End If
End Sub
-
cool, Danke :)
-
warum so komplex:
Ich verwende bei mir aus einer ansicht aus einen button:
Dim s As NotesSession
Dim doc As NotesDocument
Set s = New NotesSession
Set doc = s.DocumentContext
SetClipboardText(doc.Reason(0))
funktioniert einwandfrei
-
@robertpp:
wo hast du die Methode "SetClipboardText()" oder ("Set ClipboardText()"?) her? Ich konnte die nirgends finden..
Funktioniert die auch in der Bearbeitungsansicht einer Maske?
-
... ich vermute eine Funktion in einer Lib oder innerhalb des Aufrufes - und da wird vermutlich die WinAPI (s.o.) verwendet...
ata