Mega Code Archive

 
Categories / Delphi / VCL
 

Localize andor change MessageDlg labels and buttons

Title: Localize and/or change MessageDlg labels and buttons. Question: How can I change the dialog that MessageDlg brings up. Answer: function MessageDlgTranslated(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; HelpCtx: Longint = 0): TModalResult; begin with CreateMessageDialog(Msg, DlgType, Buttons) do try Position := poDesktopCenter; case DlgType of mtWarning: Caption := rsCaptionWarning; mtError: Caption := rsCaptionError; mtInformation: Caption := rsCaptionInformation; mtConfirmation: Caption := rsCaptionConfirmation; end; with FindChildControl('Yes') as TButton do begin Caption := rsMsgYes; if DefaultButton = mbYes then TabOrder := 0; end; with FindChildControl('No') as TButton do begin Caption := rsMsgNo; if DefaultButton = mbNo then TabOrder := 0; end; with FindChildControl('Cancel') as TButton do begin Caption := rsMsgCancel; if DefaultButton = mbCancel then TabOrder := 0; end; with FindChildControl('OK') as TButton do begin Caption := rsMsgOk; if DefaultButton = mbOK then TabOrder := 0; end; with FindChildControl('Abort') as TButton do begin Caption := rsMsgAbort; if DefaultButton = mbAbort then TabOrder := 0; end; with FindChildControl('Retry') as TButton do begin Caption := rsMsgRetry; if DefaultButton = mbRetry then TabOrder := 0; end; with FindChildControl('Ignore') as TButton do begin Caption := rsMsgIgnore; if DefaultButton = mbIgnore then TabOrder := 0; end; with FindChildControl('Yes to All') as TButton do begin Caption := rsMsgYesToAll; if DefaultButton = mbYesToAll then TabOrder := 0; end; with FindChildControl('No to All') as TButton do begin Caption := rsMsgNoToAll; if DefaultButton = mbNoToAll then TabOrder := 0; end; with FindChildControl('Help') as TButton do begin Caption := rsMsgHelp; if DefaultButton = mbHelp then TabOrder := 0; end; Result := ShowModal; finally Free; end; end;