delphiフレームなしドラッグ可能フォーム
1603 ワード
unit UFrmModless;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFrmModeless = class(TForm)
lblInfo: TLabel;
btnClose: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
private
{ Private declarations }
procedure WMNCHITTEST(var Msg:TWMNCHITTEST);message WM_NCHITTEST;
public
{ Public declarations }
procedure CreateParams(var params: TCreateParams); override;
end;
var
FrmModeless: TFrmModeless;
implementation
{$R *.dfm}
procedure TFrmModeless.CreateParams(var params: TCreateParams);
begin
inherited CreateParams(params);
params.Style := WS_THICKFRAME or WS_POPUP or WS_BORDER;
end;
procedure TFrmModeless.WMNCHITTEST(var Msg: TWMNCHITTEST);
begin
inherited;
Msg.Result:=HTCaption;
end;
procedure TFrmModeless.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
// FrmModeless := nil;
end;
procedure TFrmModeless.FormDestroy(Sender: TObject);
begin
FrmModeless := nil;
end;
procedure TFrmModeless.btnCloseClick(Sender: TObject);
begin
self.Close;
end;
end.