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
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
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/
============================================
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
TIA, Bruce
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