1

I am trying to build a chat app, and I am using C++ with the Win32 API for the graphics and networking.

I want the ability to add icons (such smilies, roses etc.) as an integral part of text lines (both for "edit" and "static" window types).

There is the naive (and extremely and clumsy solution) to show a bitmap on top of the window where it should appear, making a space between 2 words and move it as the text scroll down and up. This is almost impractical solution.

My question is - is there any good options/ideas how to incorporate small pictures (bitmaps) as icons, smilies etc. in static/edit windows types and more specifically - inside a line?

Thanks!

Niall
  • 30,036
  • 10
  • 99
  • 142

1 Answers1

1

Prinicipally there are two solutions:

  1. Use of RTF embedded graphic objects (See that question). I personally try to avoid the RTF stuff since it's pretty complicated. To "just draw some formatted text" it's doable and not too complex. (see RichEdit control in MSDN). However I never worked with embedded objects. So I don't know how complex it gets...
  2. Draw the window content (e.g. the contained text) yourself. Then you also have full control over placement of bitmaps and icons. If you need editing capabilities however (e.g. the bitmaps / icons should also be displayed when writing the text), this is probably too complicated.
Community
  • 1
  • 1
Daniel
  • 1,041
  • 7
  • 13
  • RichEdit controls support embedded images, but it is VERY complicated to get a bitmap into a RichEdit control using code. You have to use [`EM_GETOLEINTERFACE`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb788041.aspx) and [`IRichEditOle::InsertObject()`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb774355.aspx), the latter of which requires you to set up `IOleObject`, `IStorage`, and `IOleClientSite` objects to manage each bitmap you insert. Owner-drawing is less overhead, but may still not be trivial to implement depending on the type of control you are drawing on. – Remy Lebeau Aug 22 '14 at 17:31