EnglishРусский  

   ..

   clipboard.g

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

source\lib\clipboard\clipboard.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2004-2008, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * Author: Alexey Krivonogov ( gentee )
 11 *
 12 ******************************************************************************/
 13 
 14 /*-----------------------------------------------------------------------------
 15 * Id: clipboard L "Clipboard"
 16 * 
 17 * Summary: These functions are used to work with the Windows clipboard. 
 18            For using this library, it is
 19            required to specify the file clipboard.g (from lib\clipboard
 20            subfolder) with include command. #srcg[
 21 |include : $"...\gentee\lib\clipboard\clipboard.g"]   
 22 *
 23 * List: *,clipboard_gettext,clipboard_settext
 24 * 
 25 -----------------------------------------------------------------------------*/
 26 
 27 define <export>
 28 {
 29    CF_TEXT            = 1
 30    CF_BITMAP          = 2
 31    CF_METAFILEPICT    = 3
 32    CF_SYLK            = 4
 33    CF_DIF             = 5
 34    CF_TIFF            = 6
 35    CF_OEMTEXT         = 7
 36    CF_DIB             = 8
 37    CF_PALETTE         = 9
 38 }
 39 
 40 define
 41 {
 42    GMEM_FIXED         = 0x0000
 43    GMEM_MOVEABLE      = 0x0002
 44    GMEM_NOCOMPACT     = 0x0010
 45    GMEM_NODISCARD     = 0x0020
 46    GMEM_ZEROINIT      = 0x0040
 47    GMEM_MODIFY        = 0x0080
 48    GMEM_DISCARDABLE   = 0x0100
 49 }
 50 
 51 import "kernel32.dll"
 52 {
 53    uint GlobalAlloc( uint, uint )
 54    uint GlobalFree( uint )
 55    uint GlobalLock( uint )
 56    uint GlobalUnlock( uint )
 57 }
 58 
 59 import "user32.dll" 
 60 {
 61  	uint  CloseClipboard( )
 62    uint  EmptyClipboard( )
 63    uint  GetClipboardData( uint )
 64    uint  OpenClipboard( uint )
 65    uint  SetClipboardData( uint, uint )
 66 }
 67 
 68 /*-----------------------------------------------------------------------------
 69 * Id: clipboard_gettext F
 70 *
 71 * Summary: Gets a string from the clipboard.
 72 *
 73 * Params: data - Result string.    
 74 *  
 75 * Return: #lng/retpar( data ) 
 76 *
 77 -----------------------------------------------------------------------------*/
 78 
 79 func str clipboard_gettext( str data )
 80 {
 81    uint hmem ptr
 82    
 83 	data.clear()	
 84 	OpenClipboard( 0 )
 85    if hmem = GetClipboardData( $CF_TEXT )
 86    {
 87       ptr = GlobalLock( hmem )
 88       data.copy( ptr )
 89       GlobalUnlock( ptr )      
 90    }
 91    CloseClipboard( )
 92    return data
 93 }
 94 
 95 /*-----------------------------------------------------------------------------
 96 ** Id: clipboard_settext F
 97 *
 98 * Summary: Copies a string into the clipboard.
 99 *
100 * Params: data - The string for copying into the clipboard.    
101 *  
102 * Return: #lng/retf# 
103 *
104 -----------------------------------------------------------------------------*/
105 
106 func uint clipboard_settext( str data )
107 {
108    uint ret
109    uint hmem ptr
110    
111 	if !OpenClipboard( 0 ) : return 0
112 
113    hmem = GlobalAlloc( $GMEM_MOVEABLE, *data + 1 )
114    if ptr = GlobalLock( hmem )
115    {
116       mcopy( ptr, data.ptr(), *data + 1 )
117       EmptyClipboard( )
118       ret = SetClipboardData( $CF_TEXT, hmem )
119    }   
120 	CloseClipboard( )	
121    GlobalUnlock( hmem )
122    GlobalFree( hmem )
123 
124    return ret
125 }
Edit