Back to Devexpress

dxMessageDlgPosHelp(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,string,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate) Method

vcl-dxmessagedialog-dot-dxmessagedlgposhelp-x28-ad9c5f2e-x29.md

latest11.2 KB
Original Source

dxMessageDlgPosHelp(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,string,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate) Method

Opens a message dialog box associated with a help topic and positions the dialog box at specific screen coordinates. Allows you to specify the default button.

Declaration

delphi
function dxMessageDlgPosHelp(const AMessage: string; ADialogType: TMsgDlgType; AButtons: TMsgDlgButtons; AHelpContext: Longint; X: Integer; Y: Integer; const AHelpFileName: string; ADefaultButton: TMsgDlgBtn; const AHyperlinkClickProc: TdxMessageDialogHyperlinkClickDelegate = nil; const AShowHyperlinkHintProc: TdxMessageDialogShowHyperlinkHintDelegate = nil): Integer;

Parameters

NameTypeDescription
AMessagestring

Message dialog box content. The AMessage parameter value initializes the created form’s Message property.

The AMessage parameter supports a set of BBCode-inspired tags that allow you to format message box content.

| | ADialogType | TMsgDlgType |

A message dialog box type that determines the predefined caption, system icon, and sound of the message dialog box.

This parameter value initializes the created form’s DialogType property.

| | AButtons | TMsgDlgButtons |

A set of buttons on the message dialog box form.

| | AHelpContext | Longint |

A context ID of the help topic associated with the created message box. Users can click the Help button or press F1 to open the associated help topic.

| | X | Integer |

A horizontal offset (in pixels) of the upper-left dialog corner from the upper-left screen corner.

| | Y | Integer |

A vertical offset (in pixels) of the upper-left dialog corner from the upper-left screen corner.

| | AHelpFileName | string |

The name of the help file associated with the message dialog box. Users can click the Help button or press F1 to open the associated help topic.

| | ADefaultButton | TMsgDlgBtn |

Optional. A button type. Use this parameter to specify the button that has focus when the message box appears.

If this parameter is omitted, the first button on the message box has focus (TMsgDlgBtn.FirstButton).

| | AHyperlinkClickProc | TdxMessageDialogHyperlinkClickDelegate |

Optional. Specifies a procedure that handles a click on a hyperlink within the displayed message. The AHyperlinkClickProc parameter value initializes the HyperlinkClickProc property of the created message dialog box form.

You can define a click handler procedure to identify the clicked hyperlink and prevent certain links from being activated.

Tip

Refer to the TdxMessageDialogHyperlinkClickDelegate procedural type description for detailed information and a code example.

| | AShowHyperlinkHintProc | TdxMessageDialogShowHyperlinkHintDelegate |

Optional. Specifies a procedure that handles a hyperlink hint display event. The AShowHyperlinkHintProc parameter value initializes the ShowHyperlinkHintProc property of the created message dialog box form.

You can define a hyperlink hint handler procedure to change the predefined hint message (the hyperlink target URI) depending on certain conditions in your application.

Tip

Refer to the TdxMessageDialogShowHyperlinkHintDelegate procedural type description for detailed information and a code example.

|

Returns

TypeDescription
Integer

The ID of the button clicked to close the message box.

The function returns 0 if it failed to create a message box, and 2 if a user clicked the Close button or pressed Esc.

Refer to the list of possible return values in the Remarks section.

|

Remarks

Call the dxMessageDlgPosHelp function to open a message dialog box associated with a help topic supplied in a help file. The message box opens at a specified position on the screen and has a specified dialog type, message, a set of buttons, and an associated help context. The current function overload additionally allows you to specify the default button.

The created message dialog box has the mdsMessageDlg style.

Code Example: Display a Message Dialog Associated with a Help File

The code example in this section opens a message dialog box with an associated help topic at the mouse pointer position. The message dialog has a formatted message and a configured button layout (with the initially focused Cancel button). The demonstrated procedure identifies the action used to close the message box.

delphi
uses
  dxMessageDialog, // Declares the dxMessageDlgPosHelp method
  Winapi.Windows; // Declares WinAPI constants
// ...

procedure TMyForm.DemonstrateDxMessageDlgPosHelp2;
var
  AMessage, AHelpURL, AHelpFileName: string;
  AHelpContext, ACloseAction: Integer;
  ADialogType: TMsgDlgType;
  AButtons: TMsgDlgButtons;
  ADefaultButton: TMsgDlgBtn;
  APointer: TPoint;
begin
  // Define a formatted message with a hyperlink (using the BBCode-inspired markup)
  AHelpURL := 'https://docs.devexpress.com/VCL/dxMessageDialog.dxMessageDlgPosHelp(AD9C5F2E)';
  AMessage := '[URL=' + AHelpURL + ']dxMessageDlgPosHelp[/URL] opens a message dialog box ' +
    'associated with a help topic ([B]AHelpFileName[/B]) and positions the message box ' +
    'at specific screen coordinates ([B]X[/B], [B]Y[/B]). The message box has ' +
    'a formatted message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B]).' +
    sLineBreak + sLineBreak +
    'This function overload allows you to select the default button ([B]ADefaultButton[/B]).';

  ADialogType := mtInformation; // Defines the "Information" dialog title, icon, and sound
  AButtons := mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
  ADefaultButton := mbCancel; // Moves focus to the Cancel button
  AHelpContext := 0; // Retains the default help context
  APointer := Mouse.CursorPos; // Obtains mouse pointer coordinates
  AHelpFileName := '.\Help.chm'; // Defines a help file path

  // Display a message box at the mouse pointer position
  ACloseAction := 
    dxMessageDlgPosHelp(AMessage, ADialogType, AButtons, AHelpContext,
    APointer.X, APointer.Y, AHelpFileName, ADefaultButton);

  // Identify the action used to close the message box
  case ACloseAction of
    IDYES: Caption := 'Yes is clicked';
    IDNO: Caption := 'No is clicked';
    IDCANCEL: Caption := 'Cancel is clicked';
    0: Caption := 'Failed to create a message box';
  end;
end;
cpp
#include "dxMessageDialog.hpp" // Declares the dxMessageDlgPosHelp method
#include <Winapi.Windows.hpp> // Declares WinAPI constants

// Add the following linker directive to the corresponding CPP source file:
#pragma link "dxMessageDialog" // Required to use dxMessageDialog.hpp declarations
// ...

void __fastcall TMyForm::DemonstrateDxMessageDlgPosHelp2()
{
  UnicodeString AMessage, AHelpURL, AHelpFileName;
  int AHelpContext, ACloseAction;
  TMsgDlgType ADialogType;
  TMsgDlgButtons AButtons;
  TMsgDlgBtn ADefaultButton;
  TPoint APointer;

  // Define a formatted message with a hyperlink (using the BBCode-inspired markup)
  AHelpURL = "https://docs.devexpress.com/VCL/dxMessageDialog.dxMessageDlgPosHelp(AD9C5F2E)";
  AMessage =
    "[URL=" + AHelpURL + "]dxMessageDlgPosHelp[/URL] opens a message dialog box "
    "associated with a help topic ([B]AHelpFileName[/B]) and positions the message box "
    "at specific screen coordinates ([B]X[/B], [B]Y[/B]). The message box has "
    "a formatted message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B])." +
    sLineBreak + sLineBreak +
    "This function overload allows you to select the default button ([B]ADefaultButton[/B]).";

  ADialogType = mtInformation; // Defines the "Information" dialog title, icon, and sound
  AButtons = mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
  ADefaultButton = mbCancel; // Moves focus to the Cancel button
  AHelpContext = 0; // Retains the default help context
  APointer = Mouse->CursorPos; // Obtains mouse pointer coordinates
  AHelpFileName = ".\\Help.chm"; // Defines a help file path

  // Display a message box at the mouse pointer position
  ACloseAction = 
    dxMessageDlgPosHelp(AMessage, ADialogType, AButtons, AHelpContext,
    APointer.X, APointer.Y, AHelpFileName, ADefaultButton);

  // Identify the action used to close the message box
  switch (ACloseAction)
  {
    case IDYES: Caption = "Yes is clicked"; break;
    case IDNO: Caption = "No is clicked"; break;
    case IDCANCEL: Caption = "Cancel is clicked"; break;
    case 0: Caption = "Failed to create a message box"; break;
  }
}

Return Values

The return value identifies the action used to close the message box:

IDOKA user clicked the OK button to close the message box.IDCANCELA user clicked the Cancel or Close button, or pressed Esc to close the message box.IDABORTA user clicked the Abort button to close the message box.IDRETRYA user clicked the Retry button to close the message box.IDIGNOREA user clicked the Ignore button to close the message box.IDYESA user clicked the Yes button to close the message box.IDNOA user clicked the No button to close the message box. See Also

Message Dialog Boxes

TdxMessageDialogForm.Create Constructor

BBCode-Inspired Text Formatting Markup

dxMessageDialog Unit