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

Minimize button doesn't raise WM_SYSCOMMAND?

265 views
Skip to first unread message

Gabe Covert

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
I am trying to capture the minimize button in Delphi, and have gotten code
that works if you go to the program menu and choose minimize. This code
works on capturing the WM_SYSCOMMAND and checking the wParam to see if it is
SC_MINIMIZE. However, when the little minimize button is pressed in the
frame, the WM_SYSCOMMAND code does not execute. How can I tell from my
Delphi Application if this minimize button is raised? Thanks

Gabe Covert

BlueGI

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
Try the TApplication.OnMessage event to trap the message.


Gabe Covert wrote in message <7bjkah$8ts$1...@usenet41.supernews.com>...

Steven Tolleneer

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
Gabe Covert wrote in message <7bjkah$8ts$1...@usenet41.supernews.com>...
>I am trying to capture the minimize button in Delphi, and have gotten code
>that works if you go to the program menu and choose minimize. This code
>works on capturing the WM_SYSCOMMAND and checking the wParam to see if it
is
>SC_MINIMIZE. However, when the little minimize button is pressed in the
>frame, the WM_SYSCOMMAND code does not execute. How can I tell from my
>Delphi Application if this minimize button is raised? Thanks
>

Try trapping the WM_GETMINMAXINFO message.

Example:
// add this to the private section of form
procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo); message
WM_GETMINMAXINFO;

procedure TFrmPostcodes.WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
begin
with Message.MinMaxInfo^ do
begin
with ptMaxPosition do
begin
X := SomeValue;
Y := SomeValue;
end; //with
with ptMaxSize do
begin
X := SomeValue;
Y := SomeValue;
end; //with
with ptMinTrackSize do
begin
X := SomeValue;
Y := SomeValue;
end; //with
with ptMaxTrackSize do
begin
X := SomeValue;
Y := SomeValue;
end; //with
end; //with message
inherited; //Call inherited handler
end;

This gives you complete control over position and size of the form.


Hope this helps


Steven Tolleneer

Loki

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
Have you tried the
Application.OnMinimize method?
I think you can even call a
SysUtils.Abort
from within it to cancel the minimise

I haven't tried, and this may not answer your question, but I
thought I'd mention it anyway :)

Gabe Covert wrote in message <7bjkah$8ts$1...@usenet41.supernews.com>...
>I am trying to capture the minimize button in Delphi, and have gotten code
>that works if you go to the program menu and choose minimize. This code
>works on capturing the WM_SYSCOMMAND and checking the wParam to see if it
is
>SC_MINIMIZE. However, when the little minimize button is pressed in the
>frame, the WM_SYSCOMMAND code does not execute. How can I tell from my
>Delphi Application if this minimize button is raised? Thanks
>

>Gabe Covert
>
>

Robert Cerny

unread,
Mar 8, 1999, 3:00:00 AM3/8/99
to
You have to mask out the lower four bits before checking for command:
procedure TMainForm.WMSysCommand(var Message: TWMSysCommand);
begin
inherited;
case (Message.CmdType and $FFF0) of
SC_MINIMIZE :
begin
{your stuff}
end;
SC_RESTORE,
SC_MAXIMIZE :
begin
{other stuff}
end;
end;
end;


--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Gareth Elliott

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
In article <N0SE2.20$da.1...@news.siol.net>, Robert Cerny <robert.qwe.
ce...@neosys.xrs.qwe.si> writes

>You have to mask out the lower four bits before checking for command:
>procedure TMainForm.WMSysCommand(var Message: TWMSysCommand);
>begin
> inherited;
> case (Message.CmdType and $FFF0) of
> SC_MINIMIZE :
> begin
> {your stuff}
> end;
> SC_RESTORE,
> SC_MAXIMIZE :
> begin
> {other stuff}
> end;
> end;
>end;
>
>
>--
I have tried this code and it seems to ignore it when I click the
minimize button. Would there be something else Im missing ?

Gareth
--
Gareth Elliott
Software Engineer

NiSoft (UK) Limited
Unit 8, 31 Ballynahinch Road, Carryduff, BELFAST BT8 8EH
Tel: +44 (0) 1232 814121, Fax: +44 (0) 1232 813962
email: gell...@nisoft.co.uk
Internet: www.nisoft.co.uk

Robert Cerny

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
I dunno.

Maybe you forgot to declare it as message handler. Or there is another
component that "steals" the message.

Standard Sys Admin Answer #112, "Well, it works for me."

--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Gareth Elliott wrote in message ...

Steffen Haugk

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
On Tue, 09 Mar 1999 13:08:08 GMT, "Robert Cerny"
<robert.q...@neosys.xrs.qwe.si> wrote:

>I dunno.
>
>Maybe you forgot to declare it as message handler. Or there is another
>component that "steals" the message.

I found your code (or similar) somewhere else. It works fine for the
Minimize in the system menu, but not for the minimize button. Why? If
it works for the system menu it's sure hooked up properly?

thanks, Steffen

Elliott

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
I'm sorry I'm not near my PC with Delphi on it, but I'll hazard a guess on
this problem.

From the name, I'm inferring that WM_SYSCOMMAND is sent only when a command
from the system menu is selected. And that clicking on the Minimize button
doesn't do that.

There's another system message, named something like WM_SIZE, which is sent
when a form changes size, and a related one when it's minimized, maximized,
or restored. For the latter, there's a parameter value indicating which is
the case.

Check WM_SIZE and WM_GETMINMAXINFO, and look at any "See Also" in the Win32
help. Sorry I can't do the legwork from where I am.

Elliott

"I don't want to achieve immortality through my work. I want to achieve
it through not dying." -- Woody Allen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Elliott

unread,
Mar 10, 1999, 3:00:00 AM3/10/99
to
In article <7bjkah$8ts$1...@usenet41.supernews.com>,

"Gabe Covert" <nospam_...@seguetech.com> wrote:
> However, when the little minimize button is pressed in the
> frame, the WM_SYSCOMMAND code does not execute. How can I tell from
> my Delphi Application if this minimize button is raised?

Well, Gabe ol' boy, I went home and found the code snippet I use to detect
when a window is being UN-minimized. The concept is the same; you would just
write "if msg.SizeType = SIZE_MINIMIZED" instead of what I did.

==========================================
protected
procedure WMSize (var msg: TWMSize);
message WM_SIZE;
.
.
.
procedure TForm1.WMSize (var msg: TWMSize);
begin
inherited;
if (msg.SizeType = SIZE_MAXIMIZED) or (msg.SizeType = SIZE_RESTORED)
then ...
end
==========================================

I added this when I discovered that a form I'd placed off the screen was
being brought into visible range when the user clicks Minimize All Windows on
the taskbar, then clicks Undo Minimize All. Cripes, that isn't clicking the
command menu OR the minimize box--but the program detects it all the same.

0 new messages