was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

47 Visitors Online


 
...bei einem Message Dialog die Beschriftungen der Buttons ändern?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (72):  
     




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;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners