We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Bitmaps embedded in a TRichEdit control

htw
htw asked
on
Medium Priority
465 Views
Last Modified: 2013-12-03
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
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
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
htw

Author

Commented:
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.

htw

Author

Commented:
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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.