Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2000
    Location
    NY
    Posts
    332

    Copy Image to Clipboard

    Is there an action or DLL that will copy a .jpg image to the clipboard? I believe the clipboard plugin only handles text.

    I know it can be done using javascript in an html page but I'm looking for something a little more direct. Any ideas?

  2. #2
    Join Date
    Jul 2000
    Location
    NY
    Posts
    332
    I'm trying to use the user32.dll to copy an image to the clipboard. Running into a couple of problems though.

    One of the Functions I need to call is the CopyImage but this requires a "Handle" specific to an object. The Image object name assigned in AMS doesn't seem to work for this. Any one have any ideas? Here's my code so far. All the actions seem to work except the CopyImage Call (Surrounded by -------). This crashes the AMS app. A dialog message follows each action for error checking.

    ILHWND = Application.GetWndHandle();
    result = Dialog.Message("hWnd", ILHWND, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    OpenClip = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "OpenClipboard", ILHWND, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("Open Clipboard", OpenClip, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    EmptyClip = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "EmptyClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("Empty Clipboard", EmptyClip, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    ----------------------------------------------------
    hNew = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "CopyImage", "ILMain", "CF_DIB ", "0,0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("COpy Image to handle", hnew, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    ----------------------------------------------------

    SetData = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "SetClipboardData", "CF_DIB ", "hNew", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("SetData Clipboard", SetData, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    DataAvail = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "IsClipboardFormatAvailable", "CF_DIB", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("Is Available Clipboard", DataAvail, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);


    CloseClip = DLL.CallFunction(_SystemFolder .. "\\User32.dll", "CloseClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
    result = Dialog.Message("Close Clipboard", CloseClip, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

  3. #3
    Join Date
    Jul 2000
    Location
    NY
    Posts
    332
    For anyone interested I ended up going the HTML route with Javascript to copy an image to the clipboard.

    Basically I created a 1x1 web object on an AMS page and onclick of the copy button dynamically created a HTML page and load it into the web object.

    By setting an Onload javascript CopyImage function for the HTML page the Image gets copied to the clipboard.

    Works pretty well. Here's the Javascript function I used:

    <!-- CopyImage
    function copyTo(sImgID) {
    var ctrlRange = document.body.createControlRange();
    ctrlRange.add(document.all(sImgID));
    ctrlRange.execCommand("Copy");
    }
    //End CopyImage-->

    The Onload action is:

    <Body onload="JavaScript:copyImage('IMAGE')">

    Where "IMAGE" is the HTML Image ID for the image you want copied.

  4. #4
    Join Date
    Oct 2003
    Posts
    908
    Good tip!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts