1. Computing
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

September 29, 2010 at 5:34 am
(6) Aljaz says:

Works like a charm on Delphi 2010.
@Zarko: Thanks man, you are so full of ideas :)

@Andrew: Upgrade delphi OR make your own subroutine for popping-up messages where you first dimm the main form, show the actual message and then hide the dimming form.

October 15, 2012 at 9:07 am
(7) Thomas says:

Works very well till Delphi XE2!
There the dimmer form is shifted behind the main form, when the modal form pops up as I just found out.
Somebody an idea how to solve this?

Leave a Comment

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

©2013 About.com. All rights reserved.