Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi MessageDLG mit eigener Überschrift, Wie? (https://www.delphipraxis.net/69092-messagedlg-mit-eigener-ueberschrift-wie.html)

Amnon82 10. Mai 2006 08:06


MessageDLG mit eigener Überschrift, Wie?
 
Ich hab folgenden Code:

Delphi-Quellcode:
function xMessageDlg(const Msg: string; DlgType : TMsgDlgType;
                     Buttons : TMsgDlgButtons; Captions: array of string) : Integer;
var
  aMsgDlg : TForm;
  CaptionIndex,
  i : integer;
  dlgButton : TButton; // uses stdctrls
begin
  // Dlg erzeugen
  aMsgDlg := CreateMessageDialog(Msg, DlgType, buttons);
  CaptionIndex := 0;
  // alle Objekte des Dialoges testen
  for i := 0 to aMsgDlg.ComponentCount - 1 do begin
    // 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;
      // Beschriftung entsprechend Captions-array ändern
      dlgButton.Caption := Captions[CaptionIndex];
      Inc(CaptionIndex);
    end;
  end;
  Result := aMsgDlg.ShowModal;
end;
Wie kann man den Title (Überschrift) definieren?
Ich benötige einen MSGDLG wo ich die Überschrift und die Buttons selber definieren kann. Mit der Buttons-Beschriftung klappts ja, nur nicht mit dem Title.

Sharky 10. Mai 2006 08:16

Re: MessageDLG mit eigener Überschrift, Wie?
 
Zitat:

Zitat von Amnon82
... Wie kann man den Title (Überschrift) definieren?. ...

Hai Amnon82,

da der Dialog ja ein TForm ist hat diese ja auch eine Caption. Du musst also nur noch den Titel als Parameter übergeben und dann vor dem Aufruf von aMsgDlg.ShowModal die Caption setzen:
Delphi-Quellcode:
function xMessageDlg(const aCaption : string;const Msg: string; DlgType : TMsgDlgType;
                     Buttons : TMsgDlgButtons; Captions: array of string) : Integer;
.
.
begin
.
.
  aMsgDlg.Caption := aCaption;
  Result := aMsgDlg.ShowModal;
end;

Amnon82 10. Mai 2006 10:15

Re: MessageDLG mit eigener Überschrift, Wie?
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hab auch was gefunden:

http://img96.imageshack.us/img96/4356/dialogs6nq.png

Delphi-Quellcode:
MsgBox(
    STR Msg,    // address of text in message box
    STR Caption, // address of title of message box
    BOOL Silent  // determine muted sound
    INT uType   // style of message box
   );

MsgBoxEX(
    STR    Msg,         // address of text in message box
    STR    Caption,     // address of title of message box
    TPIC   MsgPic       // address of icon to show in the message box
    TIMGLST GlyphList    // address of imagelist to representing button glyphs
    TPOS   Position     // position of message box
    STR    Buttons      // adress of ButtonCaptions
    STR    Sound        // adress of sound to play when opening the message box
    BOOL   StayOnTop    // formstyle of message box
    BOOL   SetForeGround // determine if message box becomes the foreground
                             window.
    TCOLOR Color        // set the color of the message box
    BYTE   DefaultButton // sets the default button in the message box
   );
Example on how to display a message box with red fonts in message,
yesnobuttons, yesbutton's caption = 'Yeah', display a questionicon,
and default button is 2:

Delphi-Quellcode:
 Var ReturnValue : Integer;

 Procedure Sample1;
 begin
   mb_BtnYes := '&Yeah';
   mb_MsgFont := Tfont.Create;
   mb_MsgFont.Color := clRed;
   ReturnValue := MsgBox( 'This is the red message', '', False,
    MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION);
   mb_MsgFont.Free;
 end;

Example on how to display a simple message box asking for a value
from 1 to 10 represented by buttons 1 to 10, playing the soundfile
"c:\woww.wav", where default button is 5:

Delphi-Quellcode:
 Var ReturnValue : Integer;

 Procedure sample2;
 begin
   ReturnValue := MsgBoxEX('Select a value from 1 to 10', '', nil, nil,
   poOwnerFormCenter, '1|2|3|4|5|6|7|8|9|10', 'c:\woww.wav', False, False,
   clBtnFace, 5);
 end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:20 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz