Einzelnen Beitrag anzeigen

kagi3624

Registriert seit: 3. Feb 2020
138 Beiträge
 
Delphi 6 Enterprise
 
#4

AW: [Delphi 6] Ist es möglich in Meldungsfenstern ein Bild anzuzeigen.

  Alt 19. Aug 2021, 07:37
Hallo, danke für die Links, aber ich hab mir schon aus dem Internet was zusammengeklaut und es funktioniert für 32x32 Icons wunderbar.


Code:
function TForm1.MyMessageDlg(const ACaption: string; const Msg: string;
  DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): TModalResult;
var
  t: Integer;
  ADlgType: TMsgDlgType;
  MyIcon : TIcon;
begin
  MyIcon := TIcon.Create;
  try
    MyIcon.LoadFromFile('C:\path\to\my\favicon32.ico');
  except
    //ignore
  end;
  { Custom dialog has standard no TImage, so we'll change it to mtInformation, and paste our own Icon on it. }
  if DlgType = mtCustom then
    ADlgType := mtInformation
  else
    ADlgType := DlgType;
  with CreateMessageDialog(Msg, ADlgType, Buttons) do
  try
    { Title & Helpcontext }
    Caption := ACaption;
    HelpContext := HelpCtx;
    { Image }
    if DlgType = mtCustom then
      for t := 0 To ComponentCount -1 do
        if Components[t] is TImage then
           TImage(Components[t]).Picture.Icon := MyIcon;
    { Show }
    Result := ShowModal;
  finally
    Free;
  end;
end;
Und dann z.B. so benutzen

Code:
MyMessageDlg('CAPTION', 'This is a custom message!', mtCustom , [mbOk], 0);
Zitat:
Gibt's einen bestimmten Grund warum es noch D6 sein muss?
Aus dem gleichen Grund, aus dem so viele Java machen (müssen) .
  Mit Zitat antworten Zitat