Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Abgeänderte MessageDlg Func- Breitere Buttons, Caption, Icon (https://www.delphipraxis.net/22605-abgeaenderte-messagedlg-func-breitere-buttons-caption-icon.html)

Thorben86 19. Mai 2004 22:05


Abgeänderte MessageDlg Func- Breitere Buttons, Caption, Icon
 
Ich benutze die Procedure unten, um einen MSG-Dialog aufzurufen. Die Ursprungs-funktion ist aus diesem Post. Ich habe eigentlich nur den teil für die Caption hinzugefügt(klappt aber irgendwie nicht, obwohl ich auf mtCustom umgestellt hab, vielleicht könnt ihr mir ja auch sagen, was ich Falsch gemacht hab?).

Meine Frage ist nun, wie ich es schaffen kann, dass die Buttons breiter sind, da die Captions der Buttons nicht komplett angezeigt wird.

Falls ich dass auch noch mit hier fragen darf?: wie kann ich da noch ein icon angeben, dass angezeigt wird. Hab zwar versucht, den Teil dafür aus der Ursprungs-Deklaration reinzubringen, klappte aber nicht.


Delphi-Quellcode:
function MyMessageDialog(const Caption: WideString;
  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);
var antwort:TModalResult;
begin
  antwort:= MyMessageDialog('Autostart-Fehler',text, mtCustom , [mbYes ,mbNo, mbAbort],
    ['Pfad aktualisieren', 'Eintrag löschen', 'Abbrechen']);

  if antwort = mrYes then
    ShowMessage('"1" clicked')
  else if antwort = mrNo then
    ShowMessage('"2" clicked')
  else
    showmessage('"3" clicked');

end;

Robert_G 20. Mai 2004 01:45

Re: Abgeänderte MessageDlg Func- Breitere Buttons, Caption,
 
Warum änderst du nicht einfach die Breite?
Delphi-Quellcode:
    if (aMsgDlg.Components[i] is TButton) then
      with aMsgDlg.Components[i] as TButton do
      begin
        if CaptionIndex > High(Captions) then Break;

        { Give a new caption from our Captions array} 
        { Schreibe Beschriftung entsprechend Captions array}

        Caption := Captions[CaptionIndex];
        Width  := [DeinNeueBreite]; // <---

        Inc(CaptionIndex);
      end;
p.s.: Simples Copy'nPaste von Code bringt dich nicht weiter... ;)

Thorben86 20. Mai 2004 12:30

Re: Abgeänderte MessageDlg Func- Breitere Buttons, Caption,
 
Thx für die Hilfe.
Wusste nit, dass das so geht. Kenne mich noch nicht so gut mit Delphi aus, bin erst seit nem 3/4 Jahr dabei.


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:37 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-2025 by Thomas Breitkreuz