Einzelnen Beitrag anzeigen

Thorben86

Registriert seit: 20. Nov 2003
Ort: Brühl
365 Beiträge
 
Delphi 2005 Personal
 

Abgeänderte MessageDlg Func- Breitere Buttons, Caption, Icon

  Alt 19. Mai 2004, 22:05
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;
  Mit Zitat antworten Zitat