The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: minor28 on November 28, 2010, 06:00:39 PM

Title: Problem with clipboard
Post by: minor28 on November 28, 2010, 06:00:39 PM
I have copied a image from mspaint to clipboard.

This is my command button code. Neither CF_BITMAP nor CF_DIB works.

invoke OpenClipboard,0
invoke IsClipboardFormatAvailable,CF_BITMAP
.if eax
invoke GetClipboardData,CF_BITMAP
.if eax
nop
.else
invoke GetLastError
.endif
.endif
invoke closeClipboard


OpenClipboard returns TRUE
IsClipboardFormatAvailable returns TRUE
GetClipboardData returns 0
and GetLastError gives errorcode for "Thread does not have a clipboard open".

With Clipbrd.exe I can see the image but my code will not work. Cannot figure out what's wrong. Any suggestions how to solve this?

Best regards
Title: Re: Problem with clipboard
Post by: dedndave on November 28, 2010, 06:09:34 PM
not sure this applies, but.....

QuoteNot all clipboard commands are available to the user at any given time. An application should process the
WM_INITMENUPOPUP message to enable the menu items for available commands and disable unavailable commands.

http://msdn.microsoft.com/en-us/library/ms649016%28v=VS.85%29.aspx

Title: Re: Problem with clipboard
Post by: jj2007 on November 28, 2010, 06:26:14 PM
The picture is huge? Then try this link (http://www.codeproject.com/Messages/3279377/Re-EmptyClipboard-gives-an-error-1418-Thread-does-.aspx).
Title: Re: Problem with clipboard
Post by: donkey on November 28, 2010, 06:34:53 PM
Try using a window handle for the OpenClipboard call.
Title: Re: Problem with clipboard
Post by: Coma on November 28, 2010, 06:59:37 PM
Try what donkey said.
But first of all you should close the clipboard using 'CloseClipboard'
Title: Re: Problem with clipboard
Post by: minor28 on November 28, 2010, 07:59:20 PM
Thank you for your answers.

If I close the clipboard and then open it it will work with handle equ 0 as Coma suggested.

Earlier I have tryed to use a window handle for the OpenClipboard call without success. But suddenly it works with a window handle. I have been strugling with the problem a longer time so I must have changed something so it will work with a handle. So it will work as Donkey suggested without closing but with a window handle.

My huge images can't be loaded via clipboard. Mspaint uses over 1GB memory and memory page almost 2 GB before I have to terminate the app. Must be saved as files.

My WM_INITMENUPOPUP already enables and disables commands.

Thank you very much for your help.
Regards