November 19th, 2008 01:24 PM
#1
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.
November 19th, 2008 01:56 PM
#2
Re: Add Picture to rich textbox using pure win32 api
Looks more like .NET code than MFC. Try that forum.
November 19th, 2008 09:20 PM
#3
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)
November 20th, 2008 11:38 AM
#4
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
November 20th, 2008 12:40 PM
#5
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
Last edited by blastingblast; November 20th, 2008 at 12:43 PM .
November 21st, 2008 09:44 AM
#6
Re: Add Picture to rich textbox using pure win32 api
Still waiting for replies.C'mon guys, please help
February 9th, 2013 08:01 AM
#7
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.
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
Bookmarks