Hello,
I am trying to "dim" a whole tabsheet so a notification can be clearly shown - blocking the sheet itself, but not blocking the main form. I guess I'd need an alpha blended panel or a semi-transparent bitmap drawn on a TImage... never really worked with imaging until now so I'm not sure about the terms. Other than the standard components I have Graphics32 installed; can this be achieved with a custom TPanel descendant or with Graphics32 somehow? I would like not to install any 3rd party component just for this if not needed.
Worst case scenario I'll capture the tabsheet as a bitmap and draw it on a alClient panel with Canvas.Draw - which supports opacity.
Using Delphi 10.4.2 if it matters.
So, the "screenshot" and repaint dimmed works... almost.
The bitmap is captured correctly (saved to a file, shows perfectly) but drawing it back causes some issues...
I have a TPanel descendant, like...
TDimPanel= Class(TPanel)
protected
Procedure Paint; Override;
Procedure Resize; Override;
End;
Procedure TDimPanel.Resize;
Var
dc: HWND;
Begin
inherited;
_bitmap.SetSize(0, 0); // Clear the bitmap
_bitmap.SetSize(Self.Parent.Width, Self.Parent.Height);
// Self.Parent.PaintTo(_bitmap.Canvas.Handle, 0, 0); // Does not capture everything, leaves some components out...
dc := GetDC(Self.Parent.Handle);
BitBlt(_bitmap.Canvas.Handle, 0, 0, _bitmap.Width, _bitmap.Height, dc, 0, 0, SRCCOPY);
_bitmap.SaveToFile('C:\shot.bmp');
End;
Procedure TDimPanel.Paint;
Begin
inherited;
Self.Canvas.Draw(0, 0, _bitmap, 128);
// Self.Canvas.Ellipse(0, Self.Height - 20, 20, Self.Height);
End;
But only the upper half of the bitmap is drawn on the panel, bottom half is empty. If ellipse drawing is uncommented, it shows up properly. The funny thing is that if I use
Self.Canvas.Draw(0, 0, _bitmap);
all is drawn perfectly, but I loose opacity... I guess it will have something to do in how the bitmap is set up...? At the moment I have the following in the constructor:
_bitmap := Vcl.Graphics.TBitMap.Create;
_bitmap.Transparent := False;
_bitmap.PixelFormat := pf32bit;
Moving the code out of my project to a TForm and using it's canvas to paint the bitmap to has the same behaviour.
Any help is greatly appreciated, these imaging-things are way out of my league.