Einzelnen Beitrag anzeigen

ghubi01

Registriert seit: 18. Nov 2017
121 Beiträge
 
Delphi 12 Athens
 
#7

AW: Notification, falls Komponente nicht mehr sichtbar

  Alt 16. Okt 2018, 20:59
Hallo hellion,

hier hätte ich noch eine Idee:
Delphi-Quellcode:
const
  MY_MSG = WM_USER + 1;

type
  TCheckBox = class(Vcl.StdCtrls.TCheckBox)
  private
    FParantVisible: Boolean;
  protected
    procedure ParentMsg(var Msg: TMessage); Message MY_MSG;
  public
    property ParantVisible: Boolean read FParantVisible;
  end;

  TComboBox = class(Vcl.StdCtrls.TComboBox)
  private
    FParantVisible: Boolean;
  protected
    procedure ParentMsg(var Msg: TMessage); Message MY_MSG;
  public
    property ParantVisible: Boolean read FParantVisible;
  end;

  ...

procedure TCheckBox.ParentMsg(var Msg: TMessage);
begin
  FParantVisible:=Boolean(Msg.WParam);
end;

procedure TComboBox.ParentMsg(var Msg: TMessage);
begin
  FParantVisible:=Boolean(Msg.WParam);
end;

  ...

procedure TForm2.TestClick(Sender: TObject);
var
  MyMsg: TMessage;
begin
  //Nach jedem Visible-Wechsel eine Botschaft an Alle senden
  GroupBox1.Visible:=not GroupBox1.Visible;
  MyMsg.Msg:=MY_MSG;
  MyMsg.WParam:=integer(GroupBox1.Visible);
  MyMsg.LParam:=0;
  MyMsg.Result:=0;

  GroupBox1.Broadcast(MyMsg); // Die Message geht an alle Controls der GroupBox1
end;
  Mit Zitat antworten Zitat