• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1006
  • Last Modified:

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.
0
S_Warrior
Asked:
S_Warrior
  • 7
  • 6
  • 6
1 Solution
 
ginsonicCommented:
I think that you can't .
0
 
ginsonicCommented:
In case that you understand through Invisible that the Visible:=False.
0
 
S_WarriorAuthor Commented:
yes if Visible := False or just some other windows is hidding the panel.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
ginsonicCommented:
In this case you can't do this job .
0
 
FarderlornCommented:
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
 
ginsonicCommented:
Nice trick, Farderlorn :)
0
 
S_WarriorAuthor Commented:
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
 
FarderlornCommented:
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
 
S_WarriorAuthor Commented:
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
 
S_WarriorAuthor Commented:
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
 
ginsonicCommented:
If is anyway hidden , whay don't place it in a good position to capture the image ? In same time can be over.
0
 
FarderlornCommented:
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
 
FarderlornCommented:
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
 
S_WarriorAuthor Commented:
I already tried this BitBlt don't copy the image unless it showen on screen.
0
 
FarderlornCommented:
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
 
ginsonicCommented:
//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
 
FarderlornCommented:
I think this is not really a problem...

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

;-)
0
 
ginsonicCommented:
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
 
S_WarriorAuthor Commented:
EXCELLENT ANSWER.

Thank you very much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now