Uses ShellAPI;
1、//最小化
procedure TForm1.btn1Click(Sender: TObject);
var
I, J, X, Y: Word;
begin
//第一種:最小化在屏幕的左下角 ,不是常見的最小化
// WindowState := wsMinimized;
//第兒種:最小化在任務(wù)欄里面 ,是常見的最小化
postmessage(Self.Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
end;
2、//最大化/正常的按鈕
procedure TForm1.btn2Click(Sender: TObject);
var
abd: TAppBarData;
begin
if WindowState = wsMaximized then
WindowState := wsNormal
else
begin
WindowState := wsMaximized; // BorderStyle為 bsNone
abd.cbSize := sizeof(abd);
SHAppBarMessage(ABM_GETTASKBARPOS, abd); //讀取任務(wù)的區(qū)域
Self.Height := Self.Height - (abd.rc.Bottom - abd.rc.Top); //預(yù)留出任務(wù)的位置
end;
end;
3、//關(guān)閉
procedure TForm1.btn3Click(Sender: TObject);
begin
Close;
end;
4、//窗體的移動(dòng)
procedure TForm1.lbl1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=Mbleft then
begin
ReleaseCapture;
Perform(WM_NCLBUTTONDOWN,HTCAPTION,0);//消息處理
end;
end;
5、//查找應(yīng)用程序中已經(jīng)創(chuàng)建的窗體
function FindForm(FormName: string): TForm;
var
i:Integer;
begin
Result := nil;
for i:=0 to Application.ComponentCount-1 do
begin
if Application.Components[i].Name = FormName then
begin
Result := TForm(Application.Components[i]);
Break;
end;
end;
end;
|