Link to home
Start Free TrialLog in
Avatar of htw
htw

asked on

Bitmaps embedded in a TRichEdit control

I'm looking for code snippets, examples, etc. how to implement bitmaps (standard BMP files, e.g. a company logo) in a TRichEdit. I know I'll probably need to use the IRichEditOle interface (it's OK if it's NT only, since that's the only platform this software will be running on). But I haven't the foggiest where to start...
As a quite experienced Pascal programmer but a relative newbie at the Windows API, I could use all help and hints you experts can provide me.

Regards,
Erik
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is something you might want to try.....
---------------------
procedure TForm1.Button1Click(Sender: TObject);
var
  bmp : TBitmap;
  Can : TCanvas;
begin
  bmp := TBitmap.Create;
  Can := TCanvas.Create;
  try
    Bmp.LoadFromFile('E:\My Bmps\checked.bmp');
    Can.Handle := GetDC(RichEdit1.Handle);
    Can.Draw(100,100,bmp);
  finally
    Can.Free;
    bmp.Free;
  end;
end;
----------------
I hope it helps =)

Regards,
Viktor Ivanov
Avatar of htw
htw

ASKER

viktornet,

I too played with the idea to treat the RichEdit control as a canvas, and on screen this approach works OK, but it's a big hassle to print the "embedded" (or should I say overlayed, or is it underlayed? ;-)) graphics on paper.

Avatar of htw

ASKER

ZifNab,

Thanks, on a first glance this looks like the component I need! Good readable source, looks like a decent piece of code, and even if it doesn't work (haven't tried it yet) it should be a great starting point for me to set my teeth in... ;-)

Maybe one caveat: in the past (when I just started with Delphi, coming from a Clipper background) I also tried to embed OLE objects using IRichEditOLECallback (in a _much_ less sophisticated way), and while this worked under Win95, it did absolutely nothing under NT 4.0 ws. If this still is the case it shouldn't be too difficult to alter the component so it uses IRichEditOLECallback under W95 and IRichEditOLE under NT...

Anyway, thanks for the URL. Apparently a lot of great Delphi programmers are living in the eastern part of Europe!

Regards,
Erik