1

I am creating a project in Delphi and was wondering if it was is possible to create a preview of a tab. My idea is for a person to hover over the panel that takes you to the page and then it shows a preview in the hint, like when you hover over an icon in your task bar. if this is possible, would it also be possible to display the page instead of the panel as a preview and then click on it to go there? By this I mean almost like an image of the page, but my problem is that I don't want it to be a static screenshot of the page, I want it to be able to show the page as it is, with any changes made. The same applies to the hint(I.E Not a static image).

Any help, and explanations, would be greatly appreciated.

  • 2
    Yes, this is definitely possible, but it requires some work, and to make it work well, you either need to be a fairly experienced Win32/VCL developer, or spend quite a lot of time developing it. – Andreas Rejbrand May 27 '21 at 08:57
  • I don't mind spending extra time to get it to work, I really want to make my project look good as it makes up a big portion of my year mark. – Déjan Venter May 27 '21 at 08:59
  • But there are several ways to do this, and if you ask two Win32 expert developers to do this, you are likely to end up with two different implementations. So it is hard to give you any hints without actually implementing it for you, which is not ideal, especially since this is a school project. So I almost think this Q is too broad. – Andreas Rejbrand May 27 '21 at 09:06
  • This "idea" implies that all the target controls exist already, but a couple of them may not be created until being shown for the first time. – AmigoJack May 27 '21 at 10:56

1 Answers1

3

To get the current view of a TTabSheet, you should use a function much like this one:

procedure TForm81.CopySheet(TAB: TTabSheet);
var
  bmp   : TBitMap;

begin
  bmp:=TBitMap.Create;
  try
    bmp.PixelFormat:=TPixelFormat.pf24bit;
    bmp.Width:=TAB.Width; bmp.Height:=TAB.Height;
    TAB.PaintTo(BMP.Canvas,0,0);
    // Do what you need to with the bmp, ie. show it in a hint, a preview window, etc.
  finally
    bmp.Free
  end
end;

The essential method is the "PaintTo" on the TAB (and most other TControls), which draws itself onto a TCanvas (f.ex. of a TBitmap, like above).

I'll leave it up to you to fill out the "Do what you need to with the bmp, ie. show it in a hint, a preview window, etc." part :-)

HeartWare
  • 7,464
  • 2
  • 26
  • 30