技术 - PowerBasic - PowerBasic 操作剪贴板

18
08 Aug.

PowerBasic 操作剪贴板

最后更新: 2009/02/28  |  评论: 0  |  关键词: 剪贴板  

  1. Function ObjectToClip(ByVal obj As tLbl_Obj) As Long 
  2.    'Neues Format registrieren, falls nicht vorhanden  
  3.    If ISFALSE(hClipBoardFormat) Then 
  4.       hClipBoardFormat = RegisterClipboardFormat($ClipBoard_RegisterObject)  
  5.    End If 
  6.        
  7.    Dim hMem As DWORD 'handle to globally allocated memory  
  8.    Dim pMem As DWORD 'pointer to globally allocated memory  
  9.        
  10.    If OpenClipboard(0) Then 
  11.       EmptyClipboard  
  12.           
  13.       hMem = GlobalAlloc( %GMEM_MOVEABLE OR %GMEM_DDESHARE, SIZEOF(tLbl_Obj))  
  14.           
  15.       If hMem Then 
  16.          pMem = GlobalLock(hMem)  
  17.          If pMem Then 
  18.             POKE$ pMem, obj             'Maybe I have to POKE it another way?  
  19.             GlobalUnlock hMem  
  20.             SetClipboardData hClipBoardFormat, hMem  
  21.          End If 
  22.       End If 
  23.           
  24.       CloseClipboard  
  25.    End If 
  26. End Function 
  27.    
  28. Function ObjectFromClip(ByRef obj As tLbl_Obj) As Long 
  29.    Dim hMem As DWORD 'handle to clipboard object  
  30.    Dim pMem As DWORD 'pointer to globally allocated memory  
  31.    Dim objStr As String 
  32.        
  33.    If IsClipboardFormatAvailable(hClipBoardFormat) Then 
  34.       If OpenClipboard(0) Then 
  35.          hMem = GetClipboardData(hClipBoardFormat)  
  36.          pMem = GlobalLock(hMem)  
  37.          If pMem Then 
  38.             objStr = PEEK$(pMem, lstrlen(ByVal pMem))     'Maybe it isn't good, to copy peek it via string?  
  39.             TYPE SET obj = objStr  
  40.          End If 
  41.          GlobalUnlock hMem  
  42.          CloseClipboard  
  43.       End If 
  44.    End If 
  45.    Function  = pMem  
  46. End Function 

 

· 本文由 木炭 发布在《激情燃烧的木炭》 上,原文地址为:http://www.woodcoal.cn/technology/powerbasic/2008818-16370-503.html(转载请保留本信息、全文内容和链接)

发表评论

已经有 0 位朋友发表了对《PowerBasic 操作剪贴板》的看法
 
登录名:  密码:   登录  注册
评论: 
User:
Contact:
验证码:  
  [Ctrl+Enter]

关于本文

相关文章

推荐文章