|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
stop dialog form from closing
I suppose a simple one for someone.
I have a dialog form which i use to input new user info. I have an if else procedure which checks to see if the required fields have been completed, and if not shows a message. How can I stop the form from closing when the OK button is pressed. Code:
procedure TForm1.button1Click(Sender: TObject);
var
f:TAddRes;
begin
f := TAddRes.Create(Self);
try
f.ShowModal;
finally
f.Release;
end;
end;
//dialog form below
//the modalresult on the dialog form is set to mrOK
procedure TForm2.OKbuttonClick(Sender: TObject);
begin
if (TitleEdit.Text = '') or (FirstNEdit.Text = '') or (LastNEdit.Text ='')
or (PostEdit.Text = '') or (AddrMemo.Text = '')
then begin
ShowMessage('Please Complete All Required Fields');
end
else
begin
//do something
end;
end;
Last edited by lloydie-t : September 8th, 2005 at 08:15 PM. |
|
#2
|
|||
|
|||
|
I have found the resolution.
set modalresult to mrNone on the button component. If the form is successfully filled in change the modalresult to mrOK. |
|
#3
|
||||
|
||||
|
You could also call Abort;
Code:
if not SomeCondition then
begin
ShowMessage('You have not entered something');
Abort;
end;
This will prevent it from going to the inherited behaviour
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > stop dialog form from closing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|