Using Visual Studio 2013 Community.
Added #include to source code. Added Shlwapi.lib to linker. Compile and link OK.
This is the code that uses EM_INSERTIMAGE:
static void insertimage( )
{
RICHEDIT_IMAGE_PARAMETERS rip;
IStream *pStream = NULL;
DWORD grfMode = STGM_READ | STGM_SHARE_DENY_NONE;
HRESULT hr = SHCreateStreamOnFileA( "add.png", grfMode, &pStream );
if (hr == S_OK)
{
ZeroMemory( &rip, sizeof( rip ) );
rip.xWidth = 2000; // unit 0.01mm
rip.yHeight = 2000;
rip.Type = TA_BASELINE;
rip.pwszAlternateText = L"adding xyz";
rip.pIStream = pStream;
hr = SendMessage( hwndrichedit, EM_INSERTIMAGE, (WPARAM)0, (LPARAM)&rip );
if (hr == S_OK)
{
// getting here, but not getting any image or alternate text
// output on screen
}
}
}
but it does not output any image or alternative text on screen and does not put the image control words into the rtf file. I also tried SHCreateStreamOnFileEx with same negative result.
How can I make this work?