Modal results from a standard vcl form

I'm using a skinning component (themeengine) that makes my app look quite nice.  Unfortunately my message dialogs and showmessage()s look just like standard Windows fare. I have made a nice little form that I can work with but I dont know how to return modal results.
LVL 1
hibbidijiAsked:
Who is Participating?
 
esoftbgCommented:
You have to determine the ModalResult property of the Form may be on pressing of 2 or 3 it's buttons:
1. Using buttons that have a property ModalResult (TButton, TBitButton ....):
   You have to set only the property of a Button (mrOK for example) and when you press that button it will close the Form and set the Form's Property ModalResult Value with the self Value.
2. Using buttons that have not a property ModalResult (TSpeedButton ....):
procedure TForm2.SpeedButtonOKClick(Sender: TObject);
begin
  Close;
  ModalResult := mrOk;
end;

procedure TForm2.SpeedButtonCancelClick(Sender: TObject);
begin
  Close;
  ModalResult := mrCancel;
end;

procedure TForm2.SpeedButtonAbortClick(Sender: TObject);
begin
  Close;
  ModalResult := mrAbort;
end;
0
 
StevenBCommented:
Return a modal result from a form displayed with a call to ShowModal by simply calling:

ModalResult := mrOK;
0
 
hibbidijiAuthor Commented:
Can I have some code for this please?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
hibbidijiAuthor Commented:
This is just what I needed.    I have an issue that is likely unrelated and not covered in the scope of this question though I would appreciate some assistance- to your knowledge, is there any difference in form.show and form.showmodal that would cause a skinning / theme style application to not operate properly on showmodal but show properly on show?   Again, I appreciate that this is outside the original scope and I will be splitting points in this question no matter what's said, just asking...

0
 
esoftbgCommented:
I think the right way is to use the ShowModal method when Form1 expects an answer from Form2:

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  case Form2.ShowModal of
    mrOk:
    begin
      // Code about mrOk
    end;
    mrCancel:
    begin
      // Code about mrCancel
    end;
    mrYes:
    begin
      // Code about mrYes
    end;
    mrNo:
    begin
      // Code about mrNo
    end;
    mrAbort:
    begin
      // Code about mrAbort
    end;
  end;
end;

But I don't know about:
> is there any difference in form.show and form.showmodal that would cause a skinning / theme style application to not operate properly on showmodal but show properly on show
Sorry, I am not using skinning / theme style application. So my experience is not worth ....
0
 
ZhaawZSoftware DeveloperCommented:
>> is there any difference in form.show and form.showmodal that would cause a skinning / theme style application to not operate properly on showmodal but show properly on show?

I think there shouldn't. Show just shows form, ShowModal - shows form, disables main form and waits for modal result.
0
 
StevenBCommented:
You don't actually have to call Close, setting the ModalResult alone will close the modal form.
0
 
hibbidijiAuthor Commented:
Thanks folks, here come the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.