-
March 26th, 2009, 06:33 AM
#1
Problem with the clipboard
hello , sorry for my bad english ....
i have a problem with the clipbaord
i try to get a image from a picture control and to put it in the clipboard ...
I used something like that :
void SendToClipboard(void)
{
HBITMAP hBitmap = NULL;
hBitmap = (HBITMAP)SendMessage(GetDlgItem(hWnd,IDC_STATIC),STM_GETIMAGE,(WPARAM) IMAGE_BITMAP,(LPARAM) 0);
OpenClipboard(hWnd);
EmptyClipboard();
if (hBitmap)
{
SetClipboardData(CF_BITMAP, hBitmap);
CloseClipboard();
}
}
This function is called from a button ...
The first time , no problem, when i press the button , i have a correct bitmap in the clipboard ( verify with paint) but if i press the button a second time , i have an incorrect bitmap in the clipboard ... when i try to paste the bitmap in paint , i have an error message ( "erreur d'obtention des données du presse-papiers" in french)
do you have any idea ?
Thanks.
Dooug
-
March 26th, 2009, 06:46 AM
#2
Re: Problem with the clipboard
Test hBitmap value after SendImage for NULL.
Set unique ID for the picture control instead of IDC_STATIC. How many controls do you have on the dialog with IDC_STATIC ID?
-
March 26th, 2009, 07:17 AM
#3
Re: Problem with the clipboard
thanks for your response ...
I have only one control with the IDC_STATIC ID , i change the id instead of, but no effect ... the first time is ok , but not the second time except if i reload a bitmap in the Picture box ... I don't understand why ?
Last edited by douggy; March 26th, 2009 at 07:46 AM.
-
March 26th, 2009, 09:23 AM
#4
Re: Problem with the clipboard
As Alex wrote:
Originally Posted by Alex F
Test hBitmap value after SendMessage for NULL
Did you check it to be not NULL?
Victor Nijegorodov
-
March 26th, 2009, 09:39 AM
#5
Re: Problem with the clipboard
oupsss sorry
yes i check it and it not be null ...
-
March 26th, 2009, 09:48 AM
#6
Re: Problem with the clipboard
Did you check the return values of yor clipboard function to be nonzero / not NULL?
Victor Nijegorodov
-
March 26th, 2009, 10:14 AM
#7
Re: Problem with the clipboard
yes , i check all the function return , ans all is ok !!!
the return value of the SetClipboardData function is the same that the handle input parameter ...
Thanks for your help
-
March 26th, 2009, 10:19 AM
#8
Re: Problem with the clipboard
Originally Posted by douggy
the return value of the SetClipboardData function is the same that the handle input parameter ...
Then what is your problem?
Victor Nijegorodov
-
March 26th, 2009, 10:23 AM
#9
Re: Problem with the clipboard
Why don't you post the same code above with all of the changes you have made?
-
March 26th, 2009, 10:42 AM
#10
Re: Problem with the clipboard
Originally Posted by VictorN
Then what is your problem?
When i press twice the button to set the bitmap in the clipboard , i can't paste it, there is an error...
i know , i can press once the button, the second press is useless but that irritates me to not understand. In theory it should crush the old bitmap in the clipboard even if it's the same
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|