示例#1
0
void __fastcall TCustomVersionInfoLabel::SetVersionInfo(TVersionInfo* Value)
{
  if (Value != FVersionInfo)
  {
    TCMVersionInfoUi NotifcationMessage = { };
    TObject* Downcast;

    NotifcationMessage.UiElement = this;

    if (FVersionInfo != NULL)
    {
      NotifcationMessage.Msg = CM_VERSIONINFOUIDETACH;
      Downcast = FVersionInfo;
      Downcast->Dispatch(&NotifcationMessage);
    }

    FVersionInfo = Value;

    if (FVersionInfo != NULL)
    {
      NotifcationMessage.Msg = CM_VERSIONINFOUIATTACH;
      Downcast = FVersionInfo;
      Downcast->Dispatch(&NotifcationMessage);
    }

    UpdateLabelContent();
  }
}
void __fastcall TVersionInfo::DoChanged(void)
{
  TCMVersionInfoComponent NotificationMessage = { };

  NotificationMessage.Msg = CM_VERSIONINFOCHANGE;
  NotificationMessage.Component = this;
//Changed Roy:
  for (int i = 0; i < FUiElements->Count; ++i)
  {
	TObject* AnUiElement;

	// Trick: Since in our UI elements the message map as implemented
	//        through the overridden Dispatch method is not public,
	//        we down-cast to a descendant (TObject) where Dispatch is
	//        public and then call Dispatch.
	//        This technique works because Dispatch is virtual.
	AnUiElement = static_cast<TObject*>(FUiElements->Items[i]);
	assert(AnUiElement != NULL);
	AnUiElement->Dispatch(&NotificationMessage);
  }

  if (FOnChange != NULL)
  {
    FOnChange(this);
  }
}