TdxMessageDialogHyperlinkClickDelegate Type
The procedural type for a hyperlink activation handler in a message dialog.
Declaration
TdxMessageDialogHyperlinkClickDelegate = reference to procedure(AArgs: TdxHyperlinkClickEventArgs);
Parameters
Name | Type | Description |
---|---|---|
AArgs | TdxHyperlinkClickEventArgs | Stores general information on a hyperlink-related event in a DevExpress control or its UI element. |
Remarks
A click on a hyperlink defined as a part of formatted text in a message box dialog invokes the default application associated with the hyperlink’s URI scheme (a browser for HTTP/HTTPS, a mail client for MAILTO, etc.)
You can implement a handler of the TdxMessageDialogHyperlinkClickDelegate
type and pass the handler as the AHyperlinkClickProc
parameter of any message box creation method to change the behavior of hyperlinks in a message box dialog. For example, you can prevent hyperlink activation under specific conditions or execute any custom code in response to clicks on hyperlinks. This scenario can be useful if you define message box content at runtime.
Code Examples
Prevent MAILTO Hyperlink Activation in Message Boxes
The following code example prevents users from activating a hyperlink that contains the MAILTO URL scheme:
uses
System.StrUtils; // This unit declares the ContainsText global function
// ...
procedure TMyForm.LinkClickHandler(AArgs: TdxHyperlinkClickEventArgs);
begin
if(ContainsText(AArgs.URI, 'mailto')) then // If the clicked hyperlink contains the "mailto" URI scheme
AArgs.Handled := True; // Prevents hyperlink activation
end;
// This procedure displays a message box with dynamic content and prevents MAILTO links from being opened
procedure TMyForm.ShowMyMessage(const AMessage: string; const ALink: string);
begin
dxCreateMessageDialog(AMessage + #13#10 + ' [URL=' + ALink + ']' + ALink + '[/URL]', LinkClickHandler);
end;
Prevent Accidental Hyperlink Activation in Message Boxes
The code example in this section demonstrates TdxMessageDialogHyperlinkClickDelegate
and TdxMessageDialogShowHyperlinkHintDelegate handlers. The TdxMessageDialogHyperlinkClickDelegate
handler requires a user to hold down the Ctrl key to activate a hyperlink. The TdxMessageDialogShowHyperlinkHintDelegate handler changes all hyperlink hints to prompt a user to hold the Ctrl key for hyperlink activation.
procedure TMyForm.LinkClickHandler(AArgs: TdxHyperlinkClickEventArgs);
begin
if AArgs.Shift <> [ssCtrl] then // If the Ctrl key is not held down
AArgs.Handled := True; // Prevents hyperlink activation
end;
procedure TMyForm.LinkHintHandler(AArgs: TdxShowHyperlinkHintEventArgs);
var
AHintPrefix, AHintURI: string;
begin
AHintPrefix := 'Ctrl-click to navigate to ';
AHintURI := AArgs.URI.Remove(0, 8); // Removes the URI scheme from the hyperlink hint
AArgs.Hint := AHintPrefix + AHintURI; // Redefines the hyperlink hint
end;
// This procedure displays a message box with dynamic content and prevents MAILTO links from being opened
procedure TMyForm.ShowMyMessage(const AMessage: string; const ALink: string);
begin
dxCreateMessageDialog(AMessage + #13#10 + ' [URL=' + ALink + ']' + ALink + '[/URL]',
LinkClickHandler, LinkHintHandler);
end;
Direct TdxMessageDialogHyperlinkClickDelegate Type References
The following global methods reference the TdxMessageDialogHyperlinkClickDelegate
procedural type as the AHyperlinkClickProc
parameter:
dxCreateMessageDialog Overloads
- dxCreateMessageDialog(string,TMsgDlgType,TMsgDlgButtons,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Creates a message dialog box form with specified settings.
- dxCreateMessageDialog(string,TMsgDlgType,TMsgDlgButtons,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Creates a message dialog box form with the specified settings.
dxMessageBox Overloads
- dxMessageBox(THandle,string,string,Integer,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box.
- dxMessageBox(string,string,Integer,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box.
dxMessageDlg Overloads
- dxMessageDlg(string,TMsgDlgType,TMsgDlgButtons,Longint,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box.
- dxMessageDlg(string,TMsgDlgType,TMsgDlgButtons,Longint,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box.
dxMessageDlgPos Overloads
- dxMessageDlgPos(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box at the specified position on the screen.
- dxMessageDlgPos(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a modal message dialog box at the specified position on the screen.
dxMessageDlgPosHelp Overloads
- dxMessageDlgPosHelp(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,string,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a message dialog box whose help topic is supplied in a specified help file.
- dxMessageDlgPosHelp(string,TMsgDlgType,TMsgDlgButtons,Longint,Integer,Integer,string,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a message dialog box whose help topic is supplied in a specified help file.
Miscellaneous dxShowMessage Methods
- dxShowMessage(string,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes a generic message dialog box with an OK button.
- dxShowMessageFmt(string,Untyped[],TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Displays a message dialog box with a formatted message.
- dxShowMessagePos(string,Integer,Integer,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate)
- Invokes the message dialog box at the specified position on the screen.