Add Picture to rich textbox using pure win32 api
I am working on a pure win32 api(non MFC) richtextbox. I found the following code for mfc richtextboxes.
Bitmap imageObject = (Bitmap)Image.FromFile(@"C:\2.gif");
Clipboard.SetDataObject(imageObject,false);
IDataObject iData = Clipboard.GetDataObject();
bool bDataPresent = iData.GetDataPresent(DataFormats.Bitmap);
System.Drawing.Imaging.BitmapData meta = (System.Drawing.Imaging.BitmapData)iData.GetData(DataFormats.MetafilePict);
if ( bDataPresent )
richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Bitmap));
However i'm having problems converting this to pure win32. Appreciate any help in this matter.Thanks in advance.
Re: Add Picture to rich textbox using pure win32 api
Looks more like .NET code than MFC. Try that forum.
Re: Add Picture to rich textbox using pure win32 api
For pure win32 api, see Adv. Win32 api ng
news://194.177.96.26/comp.os.ms-wind...ogrammer.win32
Inserting bitmaps in RichEdit controls in C is a FAQ (since... 1995)
Re: Add Picture to rich textbox using pure win32 api
Laurentis, You suggested this link to my last question also, and I am still not sure what to do with it,Could you explain what i should do? Am still open to any ides. Thanks
Re: Add Picture to rich textbox using pure win32 api
This is the code that i have so far
//hwnd is the handle to my richtextbox
if ( OpenClipboard(hwnd) )
{
HBITMAP hbmp1=(HBITMAP)LoadImage(0,lpszFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
SetClipboardData(CF_BITMAP,hbmp1);
CloseClipboard();
SendMessage(hwnd,WM_PASTE,0,0);
}
This however seems to have no effect.Please help
Re: Add Picture to rich textbox using pure win32 api
Still waiting for replies.C'mon guys, please help
Re: Add Picture to rich textbox using pure win32 api
Too late reply from me, bit may help readers who end up searching in google:
Enable the richtext with following styles or sending message when creating it
SendMessage(hwnd, EM_CANPASTE, CF_BITMAP | CF_TEXT | CF_UNICODETEXT | CF_DIB, 0);
I hope it helps.