18
08 Aug.
PowerBasic 操作剪贴板
最后更新: 2009/02/28 | 评论: 0 | 关键词: 剪贴板
- Function ObjectToClip(ByVal obj As tLbl_Obj) As Long
- 'Neues Format registrieren, falls nicht vorhanden
- If ISFALSE(hClipBoardFormat) Then
- hClipBoardFormat = RegisterClipboardFormat($ClipBoard_RegisterObject)
- End If
- Dim hMem As DWORD 'handle to globally allocated memory
- Dim pMem As DWORD 'pointer to globally allocated memory
- If OpenClipboard(0) Then
- EmptyClipboard
- hMem = GlobalAlloc( %GMEM_MOVEABLE OR %GMEM_DDESHARE, SIZEOF(tLbl_Obj))
- If hMem Then
- pMem = GlobalLock(hMem)
- If pMem Then
- POKE$ pMem, obj 'Maybe I have to POKE it another way?
- GlobalUnlock hMem
- SetClipboardData hClipBoardFormat, hMem
- End If
- End If
- CloseClipboard
- End If
- End Function
- Function ObjectFromClip(ByRef obj As tLbl_Obj) As Long
- Dim hMem As DWORD 'handle to clipboard object
- Dim pMem As DWORD 'pointer to globally allocated memory
- Dim objStr As String
- If IsClipboardFormatAvailable(hClipBoardFormat) Then
- If OpenClipboard(0) Then
- hMem = GetClipboardData(hClipBoardFormat)
- pMem = GlobalLock(hMem)
- If pMem Then
- objStr = PEEK$(pMem, lstrlen(ByVal pMem)) 'Maybe it isn't good, to copy peek it via string?
- TYPE SET obj = objStr
- End If
- GlobalUnlock hMem
- CloseClipboard
- End If
- End If
- Function = pMem
- End Function
· 本文由 木炭 发布在《激情燃烧的木炭》 上,原文地址为:http://www.woodcoal.cn/technology/powerbasic/2008818-16370-503.html(转载请保留本信息、全文内容和链接)
发表评论