Solved

Convert Panel To Bitmap

Posted on 2002-05-19
19
869 Views
Last Modified: 2010-04-04
Hello

How can I Convert Panel to Bitmap image whan the panel that I want to convert is INVISIBLE,
and all of the control's have to be coped.

Thank you.
0
Comment
Question by:S_Warrior
  • 7
  • 6
  • 6
19 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 7019753
I think that you can't .
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7019757
In case that you understand through Invisible that the Visible:=False.
0
 

Author Comment

by:S_Warrior
ID: 7020985
yes if Visible := False or just some other windows is hidding the panel.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 9

Expert Comment

by:ginsonic
ID: 7021361
In this case you can't do this job .
0
 

Expert Comment

by:Farderlorn
ID: 7024031
If it is a panel of your application, you can do the following:

procedure TForm1.Button1Click(Sender: TObject);
var bmp1,bmp2 : tbitmap;
begin
  bmp1 := TBitMap.Create;

  //Show the panel (you will not really see it, it's too fast)
  panel1.Show;

  //Get the image of the entire form, which contains the panel
  bmp1 := GetFormImage;

  //after this hide the panel
  panel1.Hide;

  //create and prepare the destination bitmap
  bmp2 := TBitMap.Create;
  bmp2.Width := panel1.Width;
  bmp2.Height := panel1.Height;

  //copy only the part of panel from the "FormImage" in bmp1
  BitBlt(bmp2.Canvas.Handle,0,0,panel1.Width,panel1.Height,bmp1.Canvas.Handle,panel1.Left,panel1.Top,srccopy);

  //save it....or do somthing else
  bmp2.SaveToFile('MyFile.bmp');


  bmp1.Free;
  bmp2.Free;
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7026243
Nice trick, Farderlorn :)
0
 

Author Comment

by:S_Warrior
ID: 7029413
yes nice trick but it don't help me.

my real probleam is that the panel is hidden under anther panel so I can't play with the hide and show function's

also I already tred every trix's there is I realy need to find some why to do that without doing any cheap trix.
0
 

Expert Comment

by:Farderlorn
ID: 7029442
Is it your application?

If so, why you can't hide all these panels and do the trick ?

And if it isn't yours, catch the handles of the panels and you can also do it.

You have to explain your problem much more, so we don't "waste" time by trying to solve problems, that not exist.
0
 

Author Comment

by:S_Warrior
ID: 7029815
its my application,

I have object's that I load from File and into a panel,

now the panel is a small preview window in a Open dialog, I can't resize or hide the preview window.

and the panel where I am loading objects its very big, so I want to convert it into image and make a strach option!
0
 

Author Comment

by:S_Warrior
ID: 7029816
and I already tried to move the panel and copy the rect parts and then make them 2gezer, but its flickering like I dont what.
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7031255
If is anyway hidden , whay don't place it in a good position to capture the image ? In same time can be over.
0
 

Expert Comment

by:Farderlorn
ID: 7036604
Ok, think about this:

Put your or a special "Loading-panel" on an other form.
This form does not to visible on screen (Left := 2000), only visible in its options.
Then load the data or objects in this "Loading-panel".
Use the "Trick" with this new form and display the image you got.

 - Farderlorn
0
 

Expert Comment

by:Farderlorn
ID: 7036606
Ok, think about this:

Put your, or a special, "Loading-panel" on an other form.
This form HAS not to BE visible on screen (Left := 2000), only visible in its options.
Then load the data or objects in this "Loading-panel".
Use the "Trick" with this new form and display the image you got.

- Farderlorn
0
 

Author Comment

by:S_Warrior
ID: 7036863
I already tried this BitBlt don't copy the image unless it showen on screen.
0
 

Accepted Solution

by:
Farderlorn earned 200 total points
ID: 7036900
BitBlt() has nothing to do with the "shown image", because in the example, i called "Trick", it copies only one BMP to an other, and GetFormImage also works, if the form is not visible on screen, but visible by its options.

Try this, it works fine on my Delphi 6.

One form and one button.

procedure TForm1.Button1Click(Sender: TObject);
var bmp : tbitmap;
begin
 form1.Visible := true;
 form1.Left := 2000;

 ShowMessage('The form is not visible on screen now.
              I will get its image now.');

 bmp := TBitMap.Create;

 //Get the image of the entire form
 bmp := GetFormImage;

 //save it....or do somthing else
 bmp.SaveToFile('MyFile.bmp');

 bmp.Free;
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7038496
//This form HAS not to BE visible on screen (Left := 2000),

What's happening if use two or more monitors ?

Better Top:=2000; // or more

Just a suggestion ;)
0
 

Expert Comment

by:Farderlorn
ID: 7038558
I think this is not really a problem...

You can calculate the "Left" in code.
Check the monitor(s), set "Left".

;-)
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7038716
To complicated for me , a Top:=2500 is the short solution .Just a joke :P
Anyway, I belive that your solution is the right answer.
0
 

Author Comment

by:S_Warrior
ID: 7041104
EXCELLENT ANSWER.

Thank you very much!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 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