1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormConstrainedResize(Sender: TObject; var MinWidth,
MinHeight, MaxWidth, MaxHeight: Integer);
private
{ Déclarations privées }
Procedure MonMessage(var msg:Tmessage);message wm_user;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
Function ShowFenetre(P:THandle):Longint;stdcall;
implementation
{$R *.dfm}
Function ShowFenetre;
begin
with TForm1.CreateParented(p) do
try
Parent:=nil;
// ParentWindow:=p;
Result:=Handle;
Show;
except
Result:=-1;
// Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PostMessage(handle, wm_user, 1, 0);
PostMessage(handle, wm_user, 2, 0);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// Action:=caNone;
end;
procedure TForm1.MonMessage;
begin
case msg.WParam of
1:begin
SendMessage(handle, WM_NCACTIVATE, Ord(True), 0);
BringWindowToTop(Handle);
windows.SetFocus(handle);
end;
2:begin
if Width<400 then Width:=400;
if Height<200 then Height:=200;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
SendMessage(handle, wm_user, 1, 0);
end;
procedure TForm1.FormConstrainedResize(Sender: TObject; var MinWidth,
MinHeight, MaxWidth, MaxHeight: Integer);
begin
// MinHeight:=200;
// MinWidth:=400;
end; |
Partager