下の図柄がすける透明パネル
|
実行時に透明になるパネルコンポーネントです。
unit NkTransparent;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs;
type
// 透明で 背景消去を行わない コンテナウィンドウコントロール
TNkTransparent = class(TCustomControl)
private
procedure WMEraseBkGnd(var Msg: TWMEraseBkGnd);
message WM_ERASEBKGND;
protected
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
end;
procedure Register;
implementation
constructor TNkTransparent.Create;
begin
inherited;
Width := 100; Height := 100;
// 上にコントロールが貼りつけられるようにする
ControlStyle := ControlStyle + [csAcceptsControls];
end;
procedure TNkTransparent.WMEraseBkGnd;
begin
// 実行時は背景消去をしない
if csDesigning in ComponentState then inherited;
end;
procedure TNkTransParent.CreateParams(var Params: TCreateParams);
begin
inherited;
// 実行時は「透明」なウィンドウ
if not (csDesigning in ComponentState) then
Params.ExStyle := Params.Exstyle + WS_EX_TRANSPARENT;
end;
procedure Register;
begin
RegisterComponents('NakCtrl', [TNkTransparent]);
end;
end. |
|