Hi Leute!
Hab ein kleines Problem. Ich möchte gerne ein Feld in die Zwischenablage kopieren. Dafür hab ich ein lib mit dem ClipBoard.lss hier aus dem Bord importiert. Alles funktioniert bestens.
Allerdings nur beim ersten mal. Wenn mal nochmal auf den Button klickt ist die Zwischenablage leer. Beim 3. mal geht es dann wieder und so weiter. Hatte jemand das Problem schonmal?
Hier mein Code:
Aufruf:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim clsClipboard As WindowsClipboard
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set clsClipBoard = New WindowsClipboard()
clsClipboard.Contents = doc.DasFeld(0)
End Sub
Die entsprechende Lib
'ClipBoard:
Option Public
%REM
=============================================================================================
Library: ClipBoard
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Beschreibung :
Diese Bibliothek stellt eine Klasse zur Verfügung um Strings in die Zwischenablage zu schreiben oder zu lesen.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Klassen:
Bezeichnung Beschreibung
WindowsClipboard Daten in die Zwischenablage schreiben oder daraus lesen
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Benötigte Routinen und Bibliotheken:
Routine Bibliothek
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Erstellt am 02.02.2004 durch Axel Matthies
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Letzte Änderung am:
=============================================================================================
%ENDREM
Declare Private Function GetClipboardData Lib "User32" (Byval wFormat As Long) As Long
Declare Private Function SetClipboardData Lib "user32" (Byval wFormat As Long, Byval hData As Long) As Long
Declare Private Function OpenClipboard Lib "User32" Alias "OpenClipboard" (Byval hwnd As Long) As Long
Declare Private Function CloseClipboard Lib "User32" Alias "CloseClipboard" () As Long
Declare Private Function GlobalLock Lib "kernel32" Alias "GlobalLock" (Byval hMem As Long) As Long
Declare Private Function GlobalUnlock Lib "kernel32" Alias "GlobalUnlock" (Byval hMem As Long) As Long
Declare Private Function GlobalAlloc Lib "kernel32" (Byval wFlags As Long, Byval dwBytes As Long) As Long
Declare Private Function GlobalFree Lib "kernel32" (Byval hMem As Long) As Long
Declare Private Function EmptyClipboard Lib "user32" () As Long
Declare Private Function lstrcpyLP2Str Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As String, _
Byval lpString2 As Long) As Long
Declare Private Function lstrlenLP Lib "kernel32" Alias "lstrlenA" (Byval lpString As Long) As Long
Declare Private Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval strDest As Any, _
Byval lpSource As Any, Byval Length As Any)
Declare Private Function GetFocus Lib "User32" Alias "GetFocus" () As Long
Private Const CF_TEXT = 1
Private Const GMEM_MOVABLE = &H2&
Private Const GMEM_DDESHARE = &H2000&
Class WindowsClipboard
Public Property Get Contents As String
Dim hClipboard As Long
Dim LpStrl As Long
Dim Resultl As Long
Dim Clipboardstr As String
If (OpenClipboard(0&) <> 0) Then
hClipboard = GetClipboardData(CF_TEXT)
If (hClipboard <> 0) Then
LpStrl = GlobalLock(hClipboard)
Clipboardstr = Space$(lstrlenLP(LpStrl))
Resultl = lstrcpyLP2Str(Clipboardstr, LpStrl)
GlobalUnlock(hClipboard)
Else
Clipboardstr = "NULL"
End If
Call CloseClipboard()
Else
Clipboardstr = ""
End If
Contents = Clipboardstr
End Property
Public Property Set Contents As String
Dim lSize As Long
Dim hMem As Long
Dim pMemory As Long
Dim temp As Variant
lSize = Len(Contents)+1
hMem = GlobalAlloc(GMEM_MOVABLE Or GMEM_DDESHARE, lSize)
If hMem = 0 Or Isnull(hMem) Then Exit Property
pMemory = GlobalLock(hMem)
If pMemory = 0 Or Isnull(pMemory) Then
GlobalFree(hMem)
Exit Property
End If
Call MoveMemory(pMemory, Contents, lSize)
Call GlobalUnlock(hMem)
If (OpenClipboard(0&) <> 0) Then
If (EmptyClipboard() <> 0) Then
temp = SetClipboardData(CF_TEXT, hMem)
End If
temp = CloseClipboard()
End If
GlobalFree(hMem)
End Property
End Class
Jemand eine Idee woran es liegt? Finde den fehler einfach nicht. Danke im Vorraus