lcl: implement TApplication.UpdateVisible, add TWidgetset.AppSetVisible (defined only for win32 at moment) (mantis #0010544)

git-svn-id: trunk@18403 -
This commit is contained in:
paul 2009-01-24 10:07:36 +00:00
parent 40a9bce6a9
commit fefaf6be1a
7 changed files with 38 additions and 7 deletions

View File

@ -824,8 +824,24 @@ end;
procedure TApplication.UpdateVisible;
------------------------------------------------------------------------------}
procedure TApplication.UpdateVisible;
begin
function HasVisibleForms: Boolean;
var
i: integer;
begin
Result := False;
for i := 0 to Screen.CustomFormCount - 1 do
if Screen.CustomForms[i].Visible and (Screen.CustomForms[i].Parent = nil) then
begin
Result := True;
break;
end;
end;
begin
// if there are visible forms then application task bar item must be visible too
// else hide it
WidgetSet.AppSetVisible(HasVisibleForms);
end;
{------------------------------------------------------------------------------

View File

@ -352,6 +352,7 @@ begin
else
begin
inherited SetVisible(Value);
Application.UpdateVisible;
end;
//DebugLn(['[TCustomForm.SetVisible] END ',Name,':',ClassName,' ',Value,' ',(fsCreating in FFormState),' ',Visible]);
end;

View File

@ -55,7 +55,10 @@ end;
procedure TWidgetSet.AppSetTitle(const ATitle: string);
begin
Debugln('TWidgetSet.AppSetTitle is not implemented by ', ClassName);
end;
procedure TWidgetSet.AppSetVisible(const AVisible: Boolean);
begin
end;
function TWidgetSet.GetLCLCapability(ACapability: TLCLCapability): PtrUInt;

View File

@ -409,13 +409,14 @@ var
begin
FCustomForms.Add(AForm);
FCustomFormsZOrdered.Add(AForm);
if AForm is TForm then begin
if AForm is TForm then
begin
FFormList.Add(AForm);
Application.UpdateVisible;
end;
i:=FScreenHandlers[snFormAdded].Count;
i := FScreenHandlers[snFormAdded].Count;
while FScreenHandlers[snFormAdded].NextDownIndex(i) do
TScreenFormEvent(FScreenHandlers[snFormAdded][i])(Self,AForm);
TScreenFormEvent(FScreenHandlers[snFormAdded][i])(Self, AForm);
end;
{------------------------------------------------------------------------------
@ -493,9 +494,9 @@ procedure TScreen.RemoveForm(AForm: TCustomForm);
var
i: Integer;
begin
i:=FScreenHandlers[snRemoveForm].Count;
i := FScreenHandlers[snRemoveForm].Count;
while FScreenHandlers[snRemoveForm].NextDownIndex(i) do
TScreenFormEvent(FScreenHandlers[snRemoveForm][i])(Self,AForm);
TScreenFormEvent(FScreenHandlers[snRemoveForm][i])(Self, AForm);
FCustomForms.Remove(AForm);
FCustomFormsZOrdered.Remove(AForm);
FFormList.Remove(AForm);

View File

@ -98,6 +98,7 @@ type
procedure AppBringToFront; virtual; abstract;
procedure AppSetIcon(const Small, Big: HICON); virtual;
procedure AppSetTitle(const ATitle: string); virtual;
procedure AppSetVisible(const AVisible: Boolean); virtual;
function LCLPlatform: TLCLPlatform; virtual; abstract;
function GetLCLCapability(ACapability: TLCLCapability): PtrUInt; virtual;

View File

@ -187,6 +187,7 @@ type
procedure AppTerminate; override;
procedure AppSetIcon(const Small, Big: HICON); override;
procedure AppSetTitle(const ATitle: string); override;
procedure AppSetVisible(const AVisible: Boolean); override;
function InitHintFont(HintFont: TObject): Boolean; Override;
procedure AttachMenuToWindow(AMenuObject: TComponent); Override;

View File

@ -440,6 +440,14 @@ begin
{$endif}
end;
procedure TWin32WidgetSet.AppSetVisible(const AVisible: Boolean);
begin
if AVisible then
ShowWindow(FAppHandle, SW_SHOW)
else
ShowWindow(FAppHandle, SW_HIDE);
end;
function TWin32WidgetSet.LCLPlatform: TLCLPlatform;
begin
Result:= lpWin32;