Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delphi Windows don't always minimize to the taskbar

2,754 views
Skip to first unread message

Bruce Houlihan

unread,
Oct 16, 2003, 6:07:36 PM10/16/03
to
I've notice with some of my Windows utilities that automate the environment
(e.g. I can assign a minimize window command to one of my extra mouse
buttons) that Delphi app windows sometimes don't get minimized to the
taskbar as with other applications, but behave like SDI windows in
minimizing to a small title bar in the lower-left corner of the screen.

Is there an explanation for this? It's almost like Delphi forms respond to a
particular message (minimizing the window) different than other
application-environment forms.

If I click the minimize icon in the upper right corner of the screen the
window is always minimized to the taskbar.

Bruce


Ndi

unread,
Oct 16, 2003, 9:05:54 PM10/16/03
to
> If I click the minimize icon in the upper right corner of the screen the
> window is always minimized to the taskbar.

If you call Application.Minimize, it goes to taskbar. If you set
Form1.WindowState, it goes to the screen.

If you call Application.Minimize and there is no taskbar (shell), it still
goes to the screen.

--
Andrei "Ndi" Dobrin
Brainbench MVP
www.Brainbench.com


Özgür TUĞRUL

unread,
Oct 17, 2003, 5:11:55 AM10/17/03
to
if you have 2 or more forms in your application and if some form/forms is/are
showing, application will be minimized on taskbar and showing form/forms ( which
is/are not mainform of application) minimized on desktop window ... if i'm
wrong, please warn me ... (this is vaild on windows 98 operating system)

Ndi wrote:

--
============================================
Özgür TUĞRUL

Application & System Programmer
Ass. Database & System Adm.
Statistician & Research Ass.

Hacettepe University Office of the Registrar
Data Processing Department - System Room

oztu...@hacettepe.edu.tr
http://yunus.hacettepe.edu.tr/~oztugrul/
============================================


Peter Below (TeamB)

unread,
Oct 17, 2003, 5:34:09 AM10/17/03
to
In article <3f8f...@newsgroups.borland.com>, Bruce Houlihan wrote:
> I've notice with some of my Windows utilities that automate the environment
> (e.g. I can assign a minimize window command to one of my extra mouse
> buttons) that Delphi app windows sometimes don't get minimized to the
> taskbar as with other applications, but behave like SDI windows in
> minimizing to a small title bar in the lower-left corner of the screen.
>
> Is there an explanation for this? It's almost like Delphi forms respond to a
> particular message (minimizing the window) different than other
> application-environment forms.

Actually it is a matter of window styles. Delphi form-based applications have
a special windows (you don't see it since its size is 0) which owns all other
windows of the application, at least by default. This is the Application
window (its handle is in Application.Handle). The taskbar button you see for a
normal Delphi app belongs to this Application window, not to the main form,
and the Application window is the only one that has the WS_EX_APPWINDOW
extended window style. It is this style that tells Windows to create a taskbar
button for the window and minimize it to the taskbar. Forms do not have this
style and since they have an owner (on the API level, this is not the same as
the Owner of a VCL component) Windows creates no taskbar buttons for them and
minimizes the forms to the desktop. The main form actually executes some extra
code that traps the minimize request when the user clicks on the minimize
border icon, hides the main form and minimizes the Application window instead.
But it is still possible to minimize the main form to the desktop in code, by
calling ShowWindow( mainform.handle, SW_MINIMIZE ) on it instead of sending it
a WM_SYSCOMMAND message with wparam = SC_MINIMIZE (that is what the border
icon does).

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


Bruce Houlihan

unread,
Oct 17, 2003, 11:39:18 AM10/17/03
to
This helps, but the problem is that other, non-Delphi code (Windows or the
utility app) is trying to minimize the Delphi app and it's evidently
minimizing the "child" window as you describe. What I need is to be able to
trap the message that is sent in this case and then actually do the
SC_MINIMIZE or minimize the Application window in response to this. Which
message do I trap and translate to the application to minimize, i.e. how do
I trap the ShowWindow that's being sent to just the main form?

TIA, Bruce

Peter Below (TeamB)

unread,
Oct 17, 2003, 2:45:04 PM10/17/03
to
In article <3f90...@newsgroups.borland.com>, Bruce Houlihan wrote:
> This helps, but the problem is that other, non-Delphi code (Windows or the
> utility app) is trying to minimize the Delphi app and it's evidently
> minimizing the "child" window as you describe. What I need is to be able to
> trap the message that is sent in this case and then actually do the
> SC_MINIMIZE or minimize the Application window in response to this. Which
> message do I trap and translate to the application to minimize, i.e. how do
> I trap the ShowWindow that's being sent to just the main form?

That is a problem. If said other windows would do the sensible thing and send
WM_SYSCOMMAND/SC_MINIMIZE instead of using ShowWindow you would have no
problem, but there is little that is sensible in Windows programming <g>.

Your window will get a notification message, WM_SIZE, when it is minimized.
It will also get this message on other occasions, you have to check the
message parameters to figure out why you got it. This is an after-the-fact
notification, so you cannot use to prevent the window from being minimized.
You can restore it and minimize the application, however.


private
procedure wmSize( var msg: TWMSize ); message WM_SIZE;


procedure TForm2.wmSize(var msg: TWMSize);
begin
inherited;
case msg.SizeType of
SIZE_MAXHIDE: memo1.lines.add('SIZE_MAXHIDE');
SIZE_MINIMIZED: begin
memo1.lines.add('SIZE_MINIMIZED');
windowstate := wsNormal;
if not IsIconic(Application.Handle) then
Application.Minimize;
end;
SIZE_MAXSHOW: memo1.lines.add('SIZE_MAXSHOW');
SIZE_MAXIMIZED: memo1.lines.add('SIZE_MAXIMIZED');
SIZE_RESTORED: memo1.lines.add('SIZE_RESTORED');
else
memo1.lines.add('Unknown size type');
end;
end;

If the user should still be able to minimize the form to the desktop (in case
of a secondary form) you also need to handle WM_SYSCOMMAND to get aware of
that attempt.

Bruce Houlihan

unread,
Oct 17, 2003, 3:39:59 PM10/17/03
to
Thanks for your help, Peter.

Bruce

0 new messages