ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Out of mem with ClipboardGetBitmap()

I always get an out of memory error when I call

Error=ClipboardGetBitmap (&BmpID, &Available);

even if the bitmap currently in the clipboard is very tiny.

What's wrong ?
Do I have to call something before ?
-----------
Guillaume Dargaud
CNR/IFA
http://sung3.ifsi.rm.cnr.it/~dargaud/
http://sung3.ifsi.rm.cnr.it/~domec/
http://sung3.ifsi.rm.cnr.it/~chooyu/
"Chess is a foolish expedient for making idle people believe they are doing
something very clever when they are only wasting their time." - George
Bernard Shaw.
0 Kudos
Message 1 of 9
(5,313 Views)
I agree.
I wanted to something like this, but same error as Dargaud with CVI 8.0.Smiley Mad
Someone can help?
Thanx.

    hdc = GetDC(DeskHwnd);
    hdcMem = CreateCompatibleDC(hdc);
    hBitmap = CreateCompatibleBitmap(hdc, fwidth, fheight);

    if (hBitmap != 0)
    {
        SelectObject(hdcMem, hBitmap);
   
        //---------------------------------------------
        // Copy the Desktop bitmap to memory location
        // based on window coordinates.
        //---------------------------------------------
         junk = BitBlt(hdcMem, 0, 0, fwidth, fheight, hdc, rect.left, rect.top, SRCCOPY);

        //---------------------------------------------
        // Set up the Clipboard and copy bitmap
        //---------------------------------------------
        junk = OpenClipboard(DeskHwnd);
        junk = EmptyClipboard();
        SetClipboardData(CF_BITMAP, hBitmap);
        junk = CloseClipboard();
       
        ClipboardGetBitmap (&iBitmap, &junk);
        CanvasDrawBitmap (panel, PANEL_CANVAS, iBitmap, VAL_ENTIRE_OBJECT, VAL_ENTIRE_OBJECT);
        DiscardBitmap (iBitmap);
    }
   
    //---------------------------------------------
    // Clean up handles
    //---------------------------------------------
    junk = DeleteDC(hdcMem);
    junk = ReleaseDC(DeskHwnd, hdc);

0 Kudos
Message 2 of 9
(5,168 Views)
Hi bicoun,

I was able to replicate your error, but could not find a way to correct it. As such, I have filed a Corrective Action Request with the appropriate sources to find a solution for this problem.

In the meantime, I have attached an example that I believe you can use as a workaround. In the attached example, a bitmap is written to and retrieved from the clipboard. With a few modifications, I believe it should be able to solve all of your problems.

Matt Mueller
NI
0 Kudos
Message 3 of 9
(5,124 Views)
I apologize - I appear to have forgotten to post the example. However, the example is posted in the National Instruments Developer Zone at Transferring Images and Text with Clipboard Functions.
0 Kudos
Message 4 of 9
(5,104 Views)
Dear all,
 
I have run this example, but when I close, it show a panel as the attachment!
 
Do you know what's wrong with my computer please?

帖子被Jaman在08-18-2006 05:42 PM时编辑过了

Best regards
Jaman
Developing Test Sepcialist
0 Kudos
Message 5 of 9
(5,068 Views)

I am also seeing this out of memory error when I call ClipboardGetBitmap function. It works for about 89 times before it breaks. It seems like this issue is not fixed in 8.01 version.

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 6 of 9
(4,773 Views)
Hello

This issue has been fixed for CVI 8.1. If you would like to verify it, you can download the eval version of 8.1 and test it out.

Thanks

Bilal Durrani
NI
Message 7 of 9
(4,745 Views)

for people who is still using older versions try discarding bitmap(DiscardBitmap) after ClipboardGetBitmap function. Call DiscardBitmap function before you call ClipboardGetBitmap  again.

It fixed problem in my application. ClipboardGetBitmap function help does not tell you to do this.

Thanks to NI application engineer.

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 8 of 9
(4,741 Views)
Actually the help for the bitmap ID parameter for ClipboardGetBitmap does mention this. I checked versions 8.0.1 and 8.1.


ID that serves as a handle to the bitmap copied from the clipboard.

You can pass the bitmap ID to CanvasDrawBitmap and to other bitmap functions.

When you no longer need the bitmap, free it by passing the ID to DiscardBitmap.

If there is no bitmap on the clipboard, bitmapID is set to NULL. If you want to check whether a bitmap is on the clipboard but do not want to retrieve it, pass 0 for this parameter.




Bilal Durrani
NI
0 Kudos
Message 9 of 9
(4,714 Views)