Link to home
Start Free TrialLog in
Avatar of S_Warrior
S_Warrior

asked on

Convert Panel To Bitmap

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.
Avatar of ginsonic
ginsonic
Flag of Romania image

I think that you can't .
In case that you understand through Invisible that the Visible:=False.
Avatar of S_Warrior
S_Warrior

ASKER

yes if Visible := False or just some other windows is hidding the panel.
In this case you can't do this job .
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;
Nice trick, Farderlorn :)
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.
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.
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!
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.
If is anyway hidden , whay don't place it in a good position to capture the image ? In same time can be over.
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
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
I already tried this BitBlt don't copy the image unless it showen on screen.
ASKER CERTIFIED SOLUTION
Avatar of Farderlorn
Farderlorn

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
//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 ;)
I think this is not really a problem...

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

;-)
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.
EXCELLENT ANSWER.

Thank you very much!