All old applications do work correctly
that was created/started on previous
Delphi versions (7) even after they're
compiled or build again.
New projects in Delphi 2007 (2008 is still a dream <g>) set
Application.MainformOnTaskbar to true by default (in the DPR file).
This then causes the taskbar button to belong to the main form, not to
the Application window.
Add a line
Application.ShowMainform := false;
to the DPR file above the Application.Run line.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
hehe, uh, yes.
> Application.MainformOnTaskbar to true by default (in the DPR file).
> Add a line
> Application.ShowMainform := false;
just removed the whole line from the
project.dpr file, then it worked as it
was supposed to.
Thanks.
But if I use
Application.ShowMainForm:=False, it
hides the application as I in some cases
would like to - how to get the
application back visible after using this?
if fminimizeonstart then
begin
application.showmainform:= false;
application.mainform.visible:= false;
will definetely not show the mainform on
startup, but there is no way to get that
back visible after this?
application.mainform.show;
does not work.
> if fminimizeonstart then
> begin
> application.showmainform:= false;
> application.mainform.visible:= false;
>
> will definetely not show the mainform on startup, but there is no way
> to get that back visible after this?
>
> application.mainform.show;
>
> does not work.
Hm, I would expect it to work. Does the form itself show properly or
are both form and taskbar button missing?
> WHen creating new application with D2008
D2008 hasn't ben released yet.
Gambit
Show:
showwindow(application.Handle, SW_SHOW);
Hide:
ShowWindow(Application.Handle, SW_HIDE);
..these just wont work when using forms
created with d2007. On delphi 7
everything works. even i put out that
{$ifdef VER185} // delphi 2007
Application.MainFormOnTaskBar:= False;
{$endif}
into the creation, which seems to take
care of that unwanted new setting.
I want hide and show working at any
phase of application execution. After
onload the form is missing and will
never be back as it is now. On delphi 7
this minimize on start doesn't work
unless i put form back visible on the
show event.
> OnLoad:
> if fminimizeonstart then
> begin
> application.ShowMainForm:= false;
> (owner as tform).Visible:= false;
OnLoad what? VCL forms do not have an event of that name.
> Show:
> showwindow(application.Handle, SW_SHOW);
Do you also have a application.Mainform.Show in the code path here? Or,
if the application is in fact minimized (Application.Minimize called
somewhere), you should call Application.Restore as well. *Do not
minimize the main form directly by setting its Windowstate to
wsMinimized!*
>> Show:
>> showwindow(application.Handle, SW_SHOW);
>
> Do you also have a application.Mainform.Show in the code path here? Or,
> if the application is in fact minimized (Application.Minimize called
> somewhere), you should call Application.Restore as well. *Do not
> minimize the main form directly by setting its Windowstate to
> wsMinimized!*
What do you mean by this *s? I got it
all working by using exactly setting
windowstate instead of using those other
commands.
So the working result (at least on
delphi 2007) was - now I need to make
sure this same works under delphi 7 though:
//------------------------------------------------------------------------------
procedure TAPI_trayIcon.Loaded;
begin
inherited Loaded;
// minimize on startup - DOESN'T WORK!?
if not (csDesigning in
ComponentState) then
begin
if fminimizeonstart then
begin
(owner as tform).WindowState:=
wsminimized;
if not fdonothide then
begin
(*
application.ShowMainForm:= false;
(owner as tform).visible:= false;
*)
//ShowWindow(application.handle,
SW_MINIMIZE);
showWindow(application.Handle,
SW_HIDE);
fAppHidden:= true;
fvisible:= true;
end;
end;
// notify icon(s) changed
Changed;
end;
end;
//------------------------------------------------------------------------------
procedure TAPI_trayicon.Show;
begin
if (fapptitle<>'') and
(application.title='') then
begin
application.title:= fapptitle;
fapptitle:= '';
end;
if (not application.ShowMainForm) and
(not ((owner as tform).visible)) then
begin
(owner as tform).visible:= true;
ShowWindow(application.handle,
SW_MINIMIZE);
end;
if assigned(fonshow) then fonshow(self);
showwindow(application.Handle,
SW_SHOW); // show window
if (fautohideicon) then
begin
fvisible:= false;
changed;
end;
fAppHidden:= false;
end;
//------------------------------------------------------------------------------
procedure TAPI_trayIcon.Hide;
begin
if assigned(fonhide) then fonhide(self);
ShowWindow(Application.Handle,
SW_HIDE); // hide application
from tray
if (fautoshowicon) then
begin
fvisible:= true;
changed;
end;
if (fhidetitle) and
(application.title<>'') and
(fapptitle='') then
begin
fapptitle:= application.title;
application.title:= '';
end;
fAppHidden:= true;
// set hidden state to true
end;
> *Do not
> > minimize the main form directly by setting its Windowstate to
> > wsMinimized!*
> What do you mean by this *s? I got it all working by using exactly
> setting windowstate instead of using those other commands.
In the MainformOnTaskbar = false scenario minimizing the main form (by
the user, not in code) will call application.Minimize. This hides the
main form and then minimizes the Application window (which owns the
taskbar button). If you minimize the main form directly by setting the
Windowstate it can only be restored in code, not by direct user action.