?
Solved

Message dialog that allows text input.

Posted on 2003-03-23
5
Medium Priority
?
268 Views
Last Modified: 2010-04-04
Here is my problem:

I need a way to prompt the user for text input and then detect whether the user
has pressed the OK or cancel buttons.

Something like this:

if MessageDlg('Welcome to my Delphi application.  Exit now?',
    mtConfirmation, [mbYes, mbNo], 0, mbYes) = mrYes then

would be ideal, but obviously, i can't use the built in dialogs because they don't have
text boxes.

the text should be stored in a global (in the dialog form) and the button press returned to the calling window (just like the built in dialogs).

I have tried to make the dialog box during design time as a form that is simply shown when i need input, but i am having trouble informing the calling window when a button has been pressed.

The procedure that calls for the dialog box needs to call it, and then either continue the procedure using the text that the user inputs (if OK is pressed), or skip the rest of the procedure (is Cancel is pressed)

Also, I am using the MDI, and any calls will be done from child windows
and not the main form.

let me know if you need any more info.
0
Comment
Question by:SemperFudge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 280 total points
ID: 8190614
The "built in" dialogs of Delphi are no built in dialogs at all. Have a look yourself in the VCL sources.

I do not understand the problem. Use ShowModal to show your form give the buttons a ModalResult.

if DialogForm.ShowModal = mrOk then
  // access any VCL control on the DialogForm
0
 
LVL 3

Expert Comment

by:ILE
ID: 8191646

s:='Default value';
if inputquery('promprt','question',s) then
  begin
          {do something}  
  end;


:))

u think this??
:))
0
 
LVL 2

Expert Comment

by:j42
ID: 8193833
Hi,

> but i am having trouble informing the calling window
> when a button has been pressed.

you can use a callback function.



Regards
0
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 8193924
It is possible to place a edit box in a dialog box, but its easier to use ShowModal, like Robert says.
0
 

Author Comment

by:SemperFudge
ID: 8196130
thanks guys,
i am kinda new to delphi and was unaware of the modal stuff.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

741 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