Home

The Message Box and its Position

   

Introduction

The MessageDlgPos() function provides extra possibilities to the programmer. It behaves exactly like the MessageDlg() function. To create a message box based on this function, use the syntaxes:

function MessageDlgPos(	const Msg: string;
		       	DlgType: TMsgDlgType;
			Buttons: TMsgDlgButtons;
			HelpCtx: Integer;
			X: Integer;
			Y: Integer ): Integer; overload;
 
function MessageDlgPos(	const Msg: string;
			DlgType: TMsgDlgType;
			Buttons: TMsgDlgButtons;
			HelpCtx: Integer;
			X: Integer;
			Y: Integer;
			DefaultButton: TMsgDlgBtn ): Integer; overload;

Besides the same arguments as the MessageDlg() function, the MessageDlgPos() function allows you to specify the coordinates used to display the dialog box. The X argument is an integer value that specifies the distance between the left border of the screen and the left border of the dialog box. The Y argument represents the height from the top border of the screen to the top border of the dialog box. Here is an example:

procedure TForm1.btnMessageBoxClick(Sender: TObject);
begin
    MessageDlgPos('The right side of the main form displays ' +
	          'a "Read-Only" list of currently registered students.'
             + sLineBreak +
	          'This only includes students with good records.',
	          mtInformation, [mbRetry, mbIgnore],
                  0, 20, 120);
end;

This would produce:

Message Box

 

 
 

Home Copyright © 2010 FunctionX, Inc.