CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2008
    Posts
    26

    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.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Add Picture to rich textbox using pure win32 api

    Looks more like .NET code than MFC. Try that forum.

  3. #3
    Join Date
    Jan 2008
    Posts
    48

    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)

  4. #4
    Join Date
    Apr 2008
    Posts
    26

    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

  5. #5
    Join Date
    Apr 2008
    Posts
    26

    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 01:43 PM.

  6. #6
    Join Date
    Apr 2008
    Posts
    26

    Re: Add Picture to rich textbox using pure win32 api

    Still waiting for replies.C'mon guys, please help

  7. #7
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    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.
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured