PDA

View Full Version : متمایز کردن یک فرم در مقابل Minimize فرم اصلی



AliReza Vafakhah
یک شنبه 14 آذر 1389, 02:20 صبح
دوستان باز سلام
وقتی فرم اصلی برنامه Minimize میشه تمام فرم ها هم به همراهش Minimize میشه که خوب عادی هست اما من می خواهم تنها یک فرام اگر در حال نمایش بود هنگام Minimize فرم اصلی ، این فرم Minimize نشه.
با تشکر

Felony
یک شنبه 14 آذر 1389, 17:23 عصر
سوال جالبی بود ولی بلاخره راهی براش پیدا کردم ، تو بخش Private کلاس فرم اصلی برنامتون WMSysCommand رو به صورت زیر اعلان کنید :


type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMSysCommand (var Msg: TWMSysCommand) ; message WM_SYSCOMMAND;
public
{ Public declarations }
end;

و به صورت زیر کدش رو بنویسید :


procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
var
VisibleCount, i: Byte;
begin
if MSG.CmdType= SC_MINIMIZE then
begin
VisibleCount:= 0;
for i:= 0 to Application.ComponentCount - 1 do
if Application.Components[i] is TForm then
if (Application.Components[i] as TForm).Visible= True then
Inc(VisibleCount);

if VisibleCount < 3 then
begin
ShowWindow(Application.MainForm.Handle, SW_MINIMIZE);
for i:= 0 to Application.ComponentCount - 1 do
if Application.Components[i] is TForm then
if (Application.Components[i] as TForm) <> Application.MainForm then
ShowWindow((Application.Components[i] as TForm).Handle, SW_RESTORE);
end;
end;
DefaultHandler(Msg);
end;