Subject: Using Clipboard

by:
Marco Perrotti 12 Jan 1995

Introduction:

Here is a nice way to use clipboard functions and Open Script gdiHandle() function to copy a resource (ex. a bitmap) into the clipboard and then paste it into your applications (Word, Write and so on...), in a very simple way (without allocating a global memory buffer!).

Steps:

first of all you have to put a bitmap into Resource Manager, then you can put following code in a button script.

Script:



to handle buttonClick
  linkDll "user"
    INT  openClipboard(WORD)
    INT  emptyClipboard()
    WORD setClipboardData(WORD,WORD)
    INT  closeClipboard()
  end linkDll
  get openClipboard(sysWindowHandle)
  if it is not 0
    get emptyClipboard()

    -- Bitmap id 100 is in Resource Manager,
    -- however, you can also use name of a bitmap,
    -- instead of its ID number:
    -- ex. get gdiHandle(bitmap "myBitmap")

    get gdiHandle(bitmap id 100)

    -- First parameter (2) is CF_BITMAP data type

    get setClipboardData(2,it)
    get closeClipboard()					
  else
    request "Error opening clipboard"
    break to system
  end if

  -- Unlink functions from User

  unLinkDll functions "openClipboard,emptyClipboard," & \
  "setClipboardData,closeClipboard" from "user"
	
  -- Now, bitmap is in the clipboard and you can see (or use) it

  run "clipbrd.exe"
end
Try this:

draw a button, so choose a bitmap for a Normal Graphic of that button, then put following code in that button script:

to handle buttonClick
  get object of target
  if it is button
    get normalGraphic of target
    if it <> null
      send myScript it
    end if
  end if
end

to handle myScript what
  linkDll "user"
    INT  openClipboard(WORD)
    INT  emptyClipboard()
    WORD setClipboardData(WORD,WORD)
    INT  closeClipboard()
  end linkDll
  get openClipboard(sysWindowHandle)
  if it is not 0
    get emptyClipboard()
    get gdiHandle(what)
    get setClipboardData(2,it)
    get closeClipboard()					
  else
    request "Error opening clipboard"
    break to system
  end if
  unLinkDll functions "openClipboard,emptyClipboard," & \
  "setClipboardData,closeClipboard" from "user"
  run "clipbrd.exe"
end

Brian Parkhurst
Box 357260
Seattle, WA 98195-7260
206/543-9175