Click to See Complete Forum and Search --> : Question about EM_CANPASTE (richedit)


Ali Imran
July 17th, 2006, 10:43 AM
As per winapi manual and msdn, we can define cipboard formats which can be supported by or textbox (I dont know if it is specific to richedit only, no matter), I have a rich edit control,

And I want to allow paste of a bitmap copied to clipboard already.
I open mspaint, draw something then copy it to clipboard, now when I try pasting it in richedit (by presseing Ctrl+V), it does nothing at all. Although if there is a text in clipboard it is suddenly pasted after pressing Ctrl+V.

Where I already have sent message to the rich edit to accept such format


SendMessage(rich_hwnd, EM_CANPASTE, CF_BITMAP | CF_TEXT | CF_UNICODETEXT | CF_DIB,0);

I hope yo uget my point.

Any help is aprpeciated.

regards

Krishnaa
July 17th, 2006, 11:07 AM
Take a look at this one, it allows pasting Bitmap from clipboard.

http://www.codeproject.com/richedit/COleRichEditCtrl.asp

Ali Imran
July 17th, 2006, 11:16 AM
Well, if EM_CANPASTE message is answered only, that will be highly appreciated.

Krishnaa
July 17th, 2006, 11:21 AM
Well, if EM_CANPASTE message is answered only, that will be highly appreciated.

Well, you are misunderstanding EM_CANPASTE, it is not to make rich edit accept the format, but it is to Detemine if your rich edit control can accept the given format or not.

if the SendMessage returns nonzero value, that means you can paste the format you asked for.

For your reference here is what MSDN say,
EM_CANPASTE Message

--------------------------------------------------------------------------------

The EM_CANPASTE message determines whether a rich edit control can paste a specified clipboard format.

Syntax


To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) EM_CANPASTE, // message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam // = (LPARAM) () lParam; );
Parameters

wParam
Specifies the Clipboard Formats to try. To try any format currently on the clipboard, set this parameter to zero.
lParam
This parameter is not used; it must be zero.
Return Value

If the clipboard format can be pasted, the return value is a nonzero value.

If the clipboard format cannot be pasted, the return value is zero.



Message Information

Ali Imran
July 17th, 2006, 11:26 AM
ah, thanks karishna for clearing up confusion.

Now, should I use the same document you provided above, to paste bitmap type of data ?

Thanks for quick response btw.

regards

Krishnaa
July 17th, 2006, 11:31 AM
Yeah, I think going through that article and sample code would help you find a way.

Good Luck !
:thumb:

Ali Imran
July 17th, 2006, 11:39 AM
Thanks karishna :) for your time..

stay well...