unit uMainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls;
// делаем небольшой хак стандартной панели
type
TPanel = class(ExtCtrls.TPanel)
protected
procedure Paint; override;
procedure CreateParams(var Params: TCreateParams); override;
end;
type
TForm1 = class(TForm)
img1: TImage;
pnl1: TPanel;
btn1: TButton;
lbl1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TPanel.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if not (csDesigning in ComponentState) then
Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TPanel.Paint;
var
XBitMap: TBitMap;
XOldDC: HDC;
XRect: TRect;
begin
if (csDesigning in ComponentState) then
inherited Paint
else
begin
XRect := ClientRect;
XOldDC := Canvas.Handle;
XBitMap := TBitMap.Create;
try
XBitMap.Height := Height;
XBitMap.Width := Width;
Canvas.Handle := XBitMap.Canvas.Handle;
inherited Paint;
RedrawWindow(Parent.Handle, @XRect, 0, RDW_ERASE or
RDW_INVALIDATE or RDW_NOCHILDREN or RDW_UPDATENOW);
finally
Canvas.Handle := XOldDC;
Canvas.BrushCopy(XRect, XBitMap, XRect, Color);
XBitMap.Free;
end;
end;
end;
end.