![]() |
MessageDlgPos mit geänderten Buttonnamen
Ich nutze MessageDlgPos() recht oft. Wenn mein Programm in deutscher Sprache ist, aber ein englisches Windows installiert ist werden die Buttons immer als OK/Cancel, also auf Englisch angezeigt.
Ich habe eine Lösung gefunden mit der ich die Button-Captions bei so einem Dialog ändern kann:
Delphi-Quellcode:
Allerdings ist es keine Vollständige Lösung, weil ich nicht mehr die X/Y Koordinaten angeben kann wo der Dialog erscheinen soll. Auf den ersten Blick kann ich nur aMsgDlg.Position ändern.
function MyMessageDialog(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string): Integer; var aMsgDlg: TForm; i: Integer; dlgButton: TButton; CaptionIndex: Integer; begin { Create the Dialog } { Dialog erzeugen } aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons); captionIndex := 0; { Loop through Objects in Dialog } { Über alle Objekte auf dem Dialog iterieren} for i := 0 to aMsgDlg.ComponentCount - 1 do begin { If the object is of type TButton, then } { Wenn es ein Button ist, dann...} if (aMsgDlg.Components[i] is TButton) then begin dlgButton := TButton(aMsgDlg.Components[i]); if CaptionIndex > High(Captions) then Break; { Give a new caption from our Captions array} { Schreibe Beschriftung entsprechend Captions array} dlgButton.Caption := Captions[CaptionIndex]; Inc(CaptionIndex); end; end; Result := aMsgDlg.ShowModal; end; procedure TForm1.Button1Click(Sender: TObject); begin if MyMessageDialog('How much...?', mtConfirmation, mbOKCancel, ['1', '2']) = mrOk then ShowMessage('"1" clicked') else ShowMessage('"2" clicked'); end; Hat jemand eine bessere Lösung? |
AW: MessageDlgPos mit geänderten Buttonnamen
Zitat:
Delphi-Quellcode:
und in der Funktion schreibst Du dann einfach:
function MyMessageDialog(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string; ATop: Integer; ALeft: Integer): Integer;
Delphi-Quellcode:
aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
aMsgDlg.Top := ATop; aMsgDlg.Left := ALeft; |
AW: MessageDlgPos mit geänderten Buttonnamen
Danke. Vor lauter Bäumen sah ich den Wald nicht.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:20 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz