Einzelnen Beitrag anzeigen

gmc616

Registriert seit: 25. Jun 2004
Ort: Jena
627 Beiträge
 
Delphi 10.3 Rio
 
#4

Re: "Don't ask again" Messagedialog ?

  Alt 6. Apr 2009, 13:56
Das Beispiel vom Zauberer funktioniert über die WinAPI und Registry.

Ich hatte mal das gleiche Problem, wollte aber ohne die Registry auskommen. Deshalb hab ich mir selbst etwas gebastelt.
Delphi-Quellcode:
function MyMsgBoxx (psText,psTitle : string; AShowAgainChecked : boolean = false; AIcon : Integer ) : boolean;
VAR
  AMsgDialog : TForm;
  ACheckBox : TCheckBox;
  AImg : TComponent;
  bShowAgain : boolean;
  btnOk : TControl;
  nHeigth : integer;
BEGIN
  bShowAgain := true;
  AMsgDialog := CreateMessageDialog(psText, mtWarning, [mbOk]);
  AMsgDialog.FormStyle := fsStayOnTop;
  AImg := AMsgDialog.FindComponent('Image');
  if AImg <> nil then
  begin
     // eigene Icon-Lade-Funktion
     TImage(AImg).Picture.Icon := GetIconByName(IntToStr(AIcon));
  end;

  btnOk := AMsgDialog.FindChildControl('OK');
  if btnOk <> nil then
  begin
    nHeigth := btnOk.top + btnOk.Height + 24;
  end else begin
    nHeigth := 169;
  end;

  ACheckBox := TCheckBox.Create(AMsgDialog);
  WITH AMsgDialog DO
  begin
    TRY
      Caption := psTitle;
      ClientHeight := nHeigth;
      WITH ACheckBox DO
      BEGIN
          Parent := AMsgDialog;
          Caption := 'Diesen Hinweis nicht mehr anzeigen.';
          width := 190;
          top := nHeigth - 20;
          Left := 8;
          Checked := AShowAgainChecked;
      END;

      ShowModal;

      bShowAgain := Not (ACheckBox.Checked);
    FINALLY
      ACheckBox.Free;
      Free;
    END;
  END;
  Result := bShowAgain;
end;
Das ganze ist zwar (noch) nicht der Stein des Weißen, aber für mich erfüllt es seine Zwecke.
  Mit Zitat antworten Zitat