![]() |
TTaskDialog.Buttons.Add
Hallo,
weiß jemand warum TTaskDialog.Buttons.Add ein TTaskDialogBaseButtonItem Objekt und nicht ein TTaskDialogButtonItem Objekt zurückliefert? Wie füge ich per Code einen Button hinzu, dem ich auch einen CommandLinkHint setzen kann? Grüße TurboMagic |
AW: TTaskDialog.Buttons.Add
Das musst du casten. In TCustomTaskDialog.Create wird beim Erzeugen von FButtons die gewünschte Klasse angegeben, so dass der Cast auch funktioniert.
Das ist allgemein das Verhalten von Collections im Gegensatz zu generischen Listen.
Delphi-Quellcode:
constructor TCustomTaskDialog.Create(AOwner: TComponent);
begin inherited Create(AOwner); FButtons := TTaskDialogButtons.Create(Self, TTaskDialogButtonItem); FCommonButtons := [tcbOk, tcbCancel]; |
AW: TTaskDialog.Buttons.Add
Delphi-Quellcode:
with TTaskDialog.Create(self) do
try Title := 'Confirm Removal'; Caption := 'Rejbrand BookBase'; Text := Format('Are you sure that you want to remove the book file named "%s"?', [FNameOfBook]); CommonButtons := []; // <<<--- das ist entscheidend! with TTaskDialogButtonItem(Buttons.Add) do begin Caption := 'Remove'; CommandLinkHint := 'Remove the book from the catalogue.'; ModalResult := mrYes; end; with TTaskDialogButtonItem(Buttons.Add) do begin Caption := 'Keep'; CommandLinkHint := 'Keep the book in the catalogue.'; ModalResult := mrNo; end; Flags := [tfUseCommandLinks]; MainIcon := tdiNone; if Execute then if ModalResult = mrYes then DoDelete; finally Free; end ![]() |
AW: TTaskDialog.Buttons.Add
Ok, das mit dem Casten hab' ich inzwischen auch rausgefunden und das funktioniert.
Ist halt nicht gleich offensichtlich... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:39 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