[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Modal results from a standard vcl form

Posted on 2005-05-15
8
Medium Priority
?
331 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:hibbidiji
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 4

Assisted Solution

by:StevenB
StevenB earned 1000 total points
ID: 14008297
Return a modal result from a form displayed with a call to ShowModal by simply calling:

ModalResult := mrOK;
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 14008327
Can I have some code for this please?
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 1000 total points
ID: 14008369
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:hibbidiji
ID: 14008408
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
 
LVL 12

Expert Comment

by:esoftbg
ID: 14008526
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
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 14008882
>> 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
 
LVL 4

Expert Comment

by:StevenB
ID: 14009547
You don't actually have to call Close, setting the ModalResult alone will close the modal form.
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 14013194
Thanks folks, here come the points
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question