Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to minimize an application when modal forms are present (2) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Oct-02
Category
VCL-Forms
Language
Delphi 3.x
Views
95
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

My application is a non-MDI application. We use form.showmodal to call our 
application forms because we do not want more than one window at a time to be open. 
Problem: When our users minimize a window opened with showmodal, instead of 
minimizing the application, the showmodal window is minimized on the desktop. We 
need to restrict multiple windows from being open simultaneously in this 
application.

Answer:

Have a look at this unit, this form will do what you want. When minimizing the 
modal form it will minimize the app, and when restoring from the taskbar it will 
restore the app and bring the modal window back to front.

1   unit testunit;
2   
3   interface
4   
5   uses
6     Forms, SysUtils, Windows, Messages, Classes, Graphics, Controls, Dialogs, 
7   StdCtrls;
8   
9   type
10    TFormTest = class(TForm)
11    private
12      { Private declarations }
13      OldRestore: TNotifyEvent;
14      procedure MyMinimize(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
15      procedure DoRestore(Sender: TObject);
16    public
17      { Public declarations }
18    end;
19  
20  implementation
21  
22  {$R *.DFM}
23  
24  procedure TFormTest.MyMinimize(var msg: TWMSysCommand);
25  begin
26    if (msg.cmdtype and $FFF0) = SC_MINIMIZE then
27    begin
28      { the following line only for D5, not for D3, due to a bug(?) in forms.pas }
29      EnableWindow(Application.handle, true);
30      Application.Minimize;
31      OldRestore := Application.OnRestore;
32      Application.OnRestore := DoRestore;
33      msg.Result := 0;
34    end
35    else
36      inherited;
37  end;
38  
39  procedure TFormTest.DoRestore(Sender: TObject);
40  begin
41    Application.OnRestore := OldRestore;
42    SetForegroundWindow(Handle);
43  end;
44  
45  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC