Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show a modal form and process messages. 1

Status
Not open for further replies.

DelphiAaron

Programmer
Jul 4, 2002
826
AU
is it possible to show a modal form but still allow the locked form underneath to process messages ?.

Aaron
 
why would you need this?

anyway, easiest way to do this is something like this:

(quick and dirty)

Code:
procedure frmMain.ShowDialog;
var DlgClosed; // global var to detect dialog closure
begin
...
 DlgClosed := False;
 Enabled := False; // disable form to prevent mouse clicks
 frmDialog.show; //(and not showmodal)
 repeat
  Application.ProcessMessages;
  Sleep(20); // prevent 100% cpu
 until DlgClosed; // flag must be set by frmDialog (ie OnClose event)
 Enabled := True;
...
end;

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
my reason is that i use the actionmanager to control database buttons and when your playing with data on a modal form the buttons on the main form dont change till you close the modal form.

Aaron
 
the above code is pointless if its not showmodal.

the main form still processes messages if not modal.

Aaron
 
Just a thought - pass the dialog box a refrerence to the main form, then you can access whatever methods you want on the main form from the dialog. I don't have Delphi on this machine so, unfortunately I can't post a code sample


Hope this helps

[vampire][bat]
 
Aaron, offcourse it still processes messages.
It's the enabled property that should prevent a user of changing anything on the main form...

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top