form1上放一个button
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
POP:=Tpop.Create(application);
POP.BITBTN1.caption:='弹出式消息';
POP.BITBTN1.onClick:=pop.popbtnclick;
hnd:=POP.Handle;
POP.BITBTN1.tag:=hnd;
POP.SHOW;
end;
end.
------------------
窗体pop上放一个bitbtn
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Buttons;
type
Tpop = class(TForm)
BitBtn1: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure popbtnclick(sender:Tobject);
end;
var
pop: Tpop;
hnd:hwnd;
implementation
{$R *.DFM}
procedure Tpop.popbtnclick(sender:Tobject);
begin
PostMessage((sender as Tbutton).tag,WM_CLOSE,0,0);
end;
procedure Tpop.FormShow(Sender: TObject);
begin
POP.Color:=rgb(88,157,208);
end;
procedure Tpop.FormClose(Sender: TObject
var Action: TCloseAction);
begin
action:=cafree;
end;
procedure Tpop.FormDestroy(Sender: TObject);
begin
sender:=nil;
end;
end.
好不容易翻箱倒柜找出来了,很多地方值得商榷,不过表面上实现了,希望各位指正
我是节选出来地,有些传递地东西或许没用上