Home
 

Unit Dialogs


InputBox:
[Unit Dialogs]

procedure TForm1.Button1Click(Sender: TObject);
var Name : String;
begin
    Name := InputBox('Name Please:', 'Insert your name:', 'Ernie Wise');
    Label1.Caption := Name;
end;

InputQuery:
[Unit Dialogs]

procedure TForm1.Button1Click(Sender: TObject);
var S: string;
begin
    S := 'Brian Wilson';
    Label1.Caption := S;
    if InputQuery('Type your name', 'Default name', S) then
    Label1.Caption := 'Your name is ' +  ' ' + S + ' '; 
end;

Show a Message:
begin 
    ShowMessage('Remember to delete unwanted Backup Files!'); 
end;
Show a two line Message:

procedure TForm1.Button2Click(Sender: TObject);
begin
    ShowMessage('Delphi' + #13 + 'Programming!');
end;

ShowMessagePos:

procedure TForm1.Button1Click(Sender: TObject);
begin
    ShowMessagePos('Do you want to try again?',  20, 20);
end;
The 20, 20 is the position of the Message Dialog box on your screen.

MessageDlg using mtInformation:

procedure TForm1.Button1Click(Sender: TObject);
begin
    MessageDlg('Delphi is a programming language.', mtInformation, [mbOK], 0);
end;
You can replace the zero with the Help Context Number.

MessageDlg using mtWarning:

procedure TForm1.Button1Click(Sender: TObject);
begin
    MessageDlg('Delphi is the best programming language.', mtWarning, [mbOK], 0);
end;

Other types of message dialog box you can use are :
mtError, mtConfirmation.

Other types of Buttons you can have are:
mbYes, mbNo, mbCancel and mbHelp.

MessageDlgPos:

procedure TForm1.Button1Click(Sender: TObject);
begin
    MessageDlgPos('Do you want to try again?',mtConfirmation, mbYesNoCancel, 0, 200, 20);
end;

The 200, 20 is the position of the Message Dialog box on your screen.

Home