RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Dialogs.MessageDlgPos Function

Displays a message dialog box at the specified screen coordinates.

Pascal
function MessageDlgPos(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X: Integer; Y: Integer): Integer; overload;
function MessageDlgPos(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X: Integer; Y: Integer; DefaultButton: TMsgDlgBtn): Integer; overload;
C++
int MessageDlgPos(const AnsiString Msg, TMsgDlgType DlgType, TMsgDlgButtons Buttons, Longint HelpCtx, int X, int Y);
int MessageDlgPos(const AnsiString Msg, TMsgDlgType DlgType, TMsgDlgButtons Buttons, Longint HelpCtx, int X, int Y, TMsgDlgBtn DefaultButton);

Dialogs

Call MessageDlgPos to bring up a message box at a particular location when you do not need to specify a caption. (If you need to specify the caption as well, use the MessageDlg function). 

Msg is the content of the message that appears. 

DlgType indicates the purpose of the dialog. 

Buttons indicates what buttons should appear in the message box. 

HelpCtx specifies the context ID for the help topic that should appear when the user clicks the help button or presses F1 while the dialog is displayed. 

X and Y specify the screen coordinates where the dialog should appear. A value of –1 means that the message box can appear anywhere in the specified dimension. 

DefaultBtn specifies which button from among those specified by Buttons is the default button for the dialog. If DefaultBtn is mbNone, there is no default button. 

MessageDlgPos returns the value of the button the user selected. The following table lists the TMsgDlgBtn values for each type of button that can appear in the message box, and the corresponding value that is returned if the user selects that button:

TMsgDlgBtn Value 
Corresponding return value 
mbOK  
mrOK  
mbCancel  
mrCancel  
mbYes  
mrYes  
mbNo  
mrNo  
mbAbort  
mrAbort  
mbRetry  
mrRetry  
mbIgnore  
mrIgnore  
mbAll  
mrAll  
mbNoToAll  
mrNoToAll  
mbYesToAll  
mrYesToAll  

Note: If the user types Ctrl+C in the message box, the text of the message is copied to the clipboard.
 

C++ Examples: 

 

/*
This example uses a button on a form. When the user clicks
the button, a message box appears with a Yes, No, and Cancel
button on it:
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  // can't do TMsgDlgButtons() << mbYesNoCancel
  MessageDlgPos("Are you there?", mtConfirmation, mbYesNoCancel, 0, 200, 200, mbYes);
}

 

Delphi Examples: 

{
This example uses a button on a form. When the user clicks
the button, a message box appears with a Yes, No, and Cancel
button on it:
}

procedure TForm1.Button1Click(Sender: TObject);

begin
  // can't do TMsgDlgButtons() << mbYesNoCancel
  Dialogs.MessageDlgPos('Are you there?', mtConfirmation, mbYesNoCancel, 0, 200, 200, mbYes);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!