1. Home
  2. Computing & Technology
  3. Delphi Programming
photo of Zarko Gajic

Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming since 1998

Dim Out the Main Form of an Application When Modal Form is Displayed

Monday May 19, 2008
in Delphi TIPS :: Dialog windows you use to display critical information to the user are, in most cases, displayed modally. A modal form is one where the application can't continue to run until the modal (information) form is closed. Delphi's ShowMessage, InputBox and MessageDlg, for example, display a modal form to the user waiting for some action.

To emphasize the importance of a modal form and the information it presents, you could gray out the main form of the application when the modal form is activated.

Read the full article to learn how to Dim Out the Main Form of an Application When Modal Form is Displayed.

Related:

Comments

May 19, 2008 at 8:57 am
(1) Joe White says:

Wouldn’t work very well on Windows XP. The “dimmer” form would have rectangular edges, while the form it’s dimming has rounded edges at the top. So it would dim more than just your window.

May 19, 2008 at 9:55 am
(2) Claude says:

My TApplicationEvents doesn’t have an OnModalBegin or End.

May 21, 2008 at 11:50 am
(3) Ron Malizia says:

Like the idea, but my version of TapplicationEvents does not have the onModalBegin nor the onModalEnd events. (D7)
I’ll try hooking it via window message?
Thanks

May 21, 2008 at 12:12 pm
(4) Ron Malizia says:

http://delphi.newswhat.com/geoxml/forumgetthread?groupname=borland.public.delphi.rtl.win32&messageid=MPG.228c2e8f4296579f9897f0@newsgroups.borland.com&displaymode=all

DOH! too simple.

private
procedure FormModalBegin(Sender: TObject);
procedure FormModalEnd(Sender: TObject);

procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnModalBegin := FormModalBegin;
Application.OnModalEnd := FormModalEnd;

procedure TMainForm.FormModalBegin(Sender: TObject);
begin
DimmerForm.DimDisplay;
end;

procedure TMainForm.FormModalEnd(Sender: TObject);
begin
DimmerForm.Hide;
end;

Hope this helps

June 7, 2008 at 1:12 pm
(5) Andrew says:

I’ve tried this, and I also cannot get it to work, even with Ron’s code - it won’t compile, giving an ‘undeclared identifier’ when it hits the ‘onModalBegin’ part.. any suggestions? I’m using D6

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Delphi Programming

More from About.com

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2008 About.com, a part of The New York Times Company.

All rights reserved.