?
Solved

how can I create a bitmap from a rich edit box

Posted on 1998-03-29
3
Medium Priority
?
355 Views
Last Modified: 2013-12-03
I need to be able to create a bitmap from a rich edit box so I can avoid having to have my customers fonts on my machine so I can print their labels. I have tried copyrect but this requires a canvas on the control. My best bet seems to be paintto but I have had trouble grappling with device contexts.

My code to date is following. Hope someone out there can help.
var
bitmap:TBitmap;
dev:HDC;
begin
bitmap:=TBitmap.create;
try
dev:=bitmap.canvas.handle;
bitmap.height:=beamfrom.ClientHeight;
bitmap.width:=beamfrom.ClientWidth;
bitmap.pixelformat:=pfdevice;

beamfrom.paintto(dev,0,0);
beamto.Picture.Assign(bitmap);
finally
bitmap.free;
end;
end;
Regards Wayne Horrobin
0
Comment
Question by:whorrobin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
Dippen earned 400 total points
ID: 1361003
Hi!

Try this code, which uses the form's canvas to copy the rich edit into a TImage and then to disk (written in D3):

procedure TForm1.Button1Click(Sender: TObject);
var
  Dest,
  Source : TRect;

begin
  Source.Top := richedit1.Top;
  Source.Left := richedit1.Left;
  Source.Bottom := (richedit1.Top + richedit1.Height);
  Source.Right := (richedit1.Left + richedit1.Width);
  Dest.Left := 0;
  Dest.Top := 0;
  Dest.Bottom := richedit1.Height;
  Dest.Right := richedit1.Width;
  image1.Height := richedit1.Height;
  image1.Width := richedit1.Width;
  image1.Canvas.CopyRect(Dest,form1.canvas,Source);
  image1.Picture.SaveToFile('Test.BMP');
end;


0
 

Expert Comment

by:Dippen
ID: 1361004
You could make the image invisible, it should work anyway...
0
 

Author Comment

by:whorrobin
ID: 1361005
Very much appreciate the help. Great to feel that you can get some help like this when you feel completely stonewalled. Top marks!

Regards Wayne Horrobin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question