Jump to content

ComponentCount-question...


erich.wanker

Recommended Posts

Hello uniGUi-Forum,

 

On my UniFrame are different UniPanels, and i want to add extEvent to all panels at runtime..

but i get an error .. what must i correct in my code?

 

thanks for help

Erich

...
type   TUniFrame3 = class(TUniFrame)
...
var UniFrame3: TUniFrame3;  
...
uses main;
...

procedure TUniFrame3.UniSpeedButton1Click(Sender: TObject);var i:Integer;
begin


for i:=0 to UniFrame3.ComponentCount-1 do
  begin
  if UniFrame3.Components[i].ClassName= 'TUniPanel' then
    begin
      if (UniFrame3.Components[i] as TUniPanel).Tag = 1 then
      begin
      (UniFrame3.Components[i] as TUniPanel).ClientEvents.ExtEvents.Add
      ('OnMouseout=function Onmouseout(sender) { sender.body.applyStyles("background-color:#3d3d3d");}');
      (UniFrame3.Components[i] as TUniPanel).ClientEvents.ExtEvents.Add
      ('Onmouseover=function Onmouseover(sender) {sender.body.applyStyles("background-color:#FF8000");}');
      end;
    end;
  end;


end;

 

i played a little bit but following changes didn´t solve my problem...

function UniFrame3: TUniFrame3;

... 

function UniFrame3: TUniFrame3;
begin
  Result := TUniFrame3(UniMainModule.GetFormInstance(TUniFrame3));
end;

..produces a "Owner Form not found.."

 

 

 

 

 

 

Link to comment
Share on other sites

  • 2 years later...

Have also difficulties here.

I use a TUniPanel on a TUniForm with some components on it:

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to unipanel1.componentcount - 1 do begin
    TUniEdit( unipanel1.components[i] ).Color := clRed;
  end;
end;

However, unipanel1.componentcount is always 0.

What i am doing wrong here?

Link to comment
Share on other sites

  • Administrators

Have also difficulties here.

I use a TUniPanel on a TUniForm with some components on it:

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to unipanel1.componentcount - 1 do begin
    TUniEdit( unipanel1.components[i] ).Color := clRed;
  end;
end;

However, unipanel1.componentcount is always 0.

What i am doing wrong here?

 

Components[] array is a list held by the owner. Here owner of controls is MainForm not the Panel.

You need to use Controls[] array instead.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...