Message dialog that allows text input.

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.
SemperFudgeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
robert_marquardtConnect With a Mentor Commented:
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
 
ILECommented:

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


:))

u think this??
:))
0
 
j42Commented:
Hi,

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

you can use a callback function.



Regards
0
 
PeterLarsenCommented:
It is possible to place a edit box in a dialog box, but its easier to use ShowModal, like Robert says.
0
 
SemperFudgeAuthor Commented:
thanks guys,
i am kinda new to delphi and was unaware of the modal stuff.
0
All Courses

From novice to tech pro — start learning today.