[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 44.392::delphi_in_dec

Title:Borland Delphi conference
Moderator:BROUGH::DAVIES
Created:Tue Mar 12 1996
Last Modified:Fri May 30 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:33
Total number of notes:110

24.0. "How do I intercept the minimize button action ?" by 45862::16.194.208.3::sharkeya () Wed Feb 05 1997 22:19

I want to add some actions that happen when a user presses the minimise 
button.

I know I have to create an event handler for it and write some code. But I 
have no idea how to go about it. The trouble is that the 'onminimize' 
action is missing from the object imspector and that stumps me.

Anyone got some sample code that I can hack.

Thanks

Alan

T.RTitleUserPersonal
Name
DateLines
24.1METSYS::GOODWINPete Goodwin, DEC/EDI EngineeringThu Feb 06 1997 09:307
    Wouldn't you write a message handler?
    
    procedure OnWMMinimize(var msg: TMessage); message WM_MINIMIZE;
    
    ...something like that, the exact syntax escapes me!
    
    Pete
24.2This is all new to me45862::16.194.208.3::sharkeyaThu Feb 06 1997 09:494
Yes, but how does it get called ?

Alan

24.3METSYS::GOODWINPete Goodwin, DEC/EDI EngineeringThu Feb 06 1997 15:447
    Er, not sure I understand...
    
    You put it in the form you want to override the handler for. Then, when
    that form gets a WM_MINIMIZE, your handler will be called. Take a look
    at the Messages section in Help. That may help confuse you further!
    
    Pete
24.4here we go !45862::SHARKEYALoginN - even makes the coffee@Thu Feb 06 1997 17:227
    OK - I'll have a go. I also had an answer from the Borland forum which
    seems to make it a bit clearer.
    
    I'll let you know what happens.
    
    Alan
    
24.5The working solution45862::16.194.208.3::sharkeyaFri Feb 07 1997 10:4825
This is it.

In the declaration for the form, add this:

  public
  procedure WMSysCommand(var Message: TWMSysCommand);message WM_SYSCOMMAND;
    { Public declarations }
  end;
 

Then write the method.

procedure TNotiform.WMSysCommand(var Message: TWMSysCommand);
begin
Inherited;
if(Message.CmdType and $FFF0 = SC_MINIMIZE) then begin
        if HideIcon then
            ShowWindow(application.handle,sw_hide);
end;
 

Easy when you know how.

Alan