Solved

Convert Panel To Bitmap

Posted on 2002-05-19
19
851 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
Comment Utility
I think that you can't .
0
 
LVL 9

Expert Comment

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

Author Comment

by:S_Warrior
Comment Utility
yes if Visible := False or just some other windows is hidding the panel.
0
 
LVL 9

Expert Comment

by:ginsonic
Comment Utility
In this case you can't do this job .
0
 

Expert Comment

by:Farderlorn
Comment Utility
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
Comment Utility
Nice trick, Farderlorn :)
0
 

Author Comment

by:S_Warrior
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:S_Warrior
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I already tried this BitBlt don't copy the image unless it showen on screen.
0
 

Accepted Solution

by:
Farderlorn earned 200 total points
Comment Utility
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
Comment Utility
//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
Comment Utility
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
Comment Utility
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
Comment Utility
EXCELLENT ANSWER.

Thank you very much!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now