Thema: Delphi Frage zu MessageDlg

Einzelnen Beitrag anzeigen

Benutzerbild von dahead
dahead

Registriert seit: 16. Mai 2005
620 Beiträge
 
#8

Re: Frage zu MessageDlg

  Alt 2. Aug 2005, 23:48
also ich poste mal das, was ich dachte bei diesem thread stand. hier der daraus entstandene code:

Delphi-Quellcode:

function MyMessageDlg(const Msg: String; DlgType: TMsgDlgType;
 Buttons: TMsgDlgButtons; Captions: Array of String): Integer;
var
  aMsgDlg: TForm;
  I: Integer;
  DlgButton: TButton;
  CaptionIndex: Integer;
begin
  aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
  CaptionIndex := 0;

  for I := 0 to aMsgDlg.ComponentCount - 1 do
  begin
   if (aMsgDlg.Components[i] is TButton) then
   begin
    DlgButton := TButton(aMsgDlg.Components[I]);
    if CaptionIndex > High(Captions) then
     Break; // Keine weiteren Buttons da

    DlgButton.Caption := Captions[CaptionIndex]; //<- ändern

    // Todo: MyMessageDlg: Problem bei zu langen Captions wird die
    // Buttonbreite nicht geändert.
    //DlgButton.Width :=
    //DlgButton.Left :=

    Inc(CaptionIndex);
   end;
  end;

 Result := aMsgDlg.ShowModal;
end;
  Mit Zitat antworten Zitat