1

I'm using an extended RichTextBox control in my application to generate RTF documents with embedded images. I'm embedding the images as EMF metafiles with {\pict\wmetafile8\picw[A]\pich[B]\picwgoal[C]\pichgoal[D]...

In Windows XP SP1, Windows Vista, and Windows 7, the documents are generated correctly, and I can see not only images in my documents, but also images contained within tables.

However, running the application in Windows 8, I can see the embedded images only if they're not contained within a table.

I understand Windows 8 uses a new version of the RichEdit control, and I suspect my application is not finding RICHEDIT50W within msftedit.dll, and is therefore falling back to the older version that Windows 8 includes for backward compatibility.

Here's the code my extended RichTextBox control uses to load the appropriate library:

Private Shared Function LoadLibrary(ByVal lpFileName As String) As IntPtr
End Function

Protected Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        Dim lResult As IntPtr = LoadLibrary("msftedit.dll")
        If lResult = IntPtr.Zero Then
            MessageBox.Show(Marshal.GetLastWin32Error().ToString())
        End If
        Dim cp As CreateParams = MyBase.CreateParams
        cp.ClassName = "RICHEDIT50W"
        Return cp
    End Get
End Property

Without fishing around for the right value, should cp.ClassName be something else in Windows 8 to load the appropriate base control, or is embedding images within tables something that got lost in the new editor?

MCattle
  • 2,897
  • 2
  • 38
  • 54
  • For what it's worth, I've tried `RICHEDIT51W`, `RICHEDIT60W`, and `RICHEDIT80W`, all of which raise exceptions when I try to send a message to the control. – MCattle Jun 04 '13 at 13:54
  • You might want to try to copy a win7 dll and then call that dll within your application. I have done that and it works. Do not replace your system32 dll by the one from win7 just make a copy of it put it inside your app folder(bin\debug) and call that dll instead – Rui Nov 04 '13 at 13:06
  • I could do that, but I suspect I may run into distribution / licensing issues. – MCattle Nov 04 '13 at 15:54
  • well i'm not sure about that, you can always try to contact the msdn forums admin and see what do they say.. – Rui Nov 05 '13 at 11:16

1 Answers1

1
  • Open wordpad
  • Open spy++ (usually bundled with VS)
  • Press Ctrl + F (or click on search)
  • drag drop bulls eye from search window on the richtext control of wordpad
  • spy++ will show the richedit class name
Vittala
  • 11
  • 1