Board index » delphi » NEWBIE: making my own error messages.

NEWBIE: making my own error messages.

I got this small program to experiment some stuff in Delphi 5.

Sometimes, a button may not be pressed at that moment (an other
action has to be taken first), so I would like to make a pop-up message
that says: No, yuo've got to do blabla first!, with an OK button beneth it.

Is this done easily in code, or do I have to create a second frame ???

Thanks in advance
Mephix

 

Re:NEWBIE: making my own error messages.


This is quite simple in fact..
Use a flag to notify that your action is complete

In Private (or public)
  YourFlagHere : Boolean;

procedure TForm1.FormCreate(Sender: TObject);
Begin
  YourFlagHere := False;
End;

Procedure SomeProcOfYourThatNeedToBeDoneFirstHere;
Begin
  [Place your code here]
  ...
  YourFlagHere := True;
End;

procedure TForm1.Button1Click(Sender: TObject);
begin
  If Not YourFlagHere Then
    MessageDlg('Your Error msg here', mtWarning,[mbOK],0)
  Else
    Begin
       [Place your code here]
    End;
end

Mike

--
Nature limits what we can DO
Science limits what we can UNDERSTAND
Theorie what we can THINK
and Religion what we can HOPE

Mephix <ow...@mephix.com> a crit dans le message :
VCCG5.813171$Kw2.7709665@flipper...

Quote
> I got this small program to experiment some stuff in Delphi 5.

> Sometimes, a button may not be pressed at that moment (an other
> action has to be taken first), so I would like to make a pop-up message
> that says: No, yuo've got to do blabla first!, with an OK button beneth
it.

> Is this done easily in code, or do I have to create a second frame ???

> Thanks in advance
> Mephix

Re:NEWBIE: making my own error messages.


The better solution is not to make the OK-button available until it is safe
to use it. Make the button's enabled property false (in design or in the
initialization section of the form) and set enabled true when external
conditions are correct.

--

Alex Haerens
AHA-design

alexhaerens _at_ hotmail _dot_ com

Mephix <ow...@mephix.com> schreef in berichtnieuws
VCCG5.813171$Kw2.7709665@flipper...
| I got this small program to experiment some stuff in Delphi 5.
|
| Sometimes, a button may not be pressed at that moment (an other
| action has to be taken first), so I would like to make a pop-up message
| that says: No, yuo've got to do blabla first!, with an OK button beneth
it.
|
| Is this done easily in code, or do I have to create a second frame ???
|
| Thanks in advance
| Mephix
|
|

Other Threads