erich.wanker Posted June 4, 2013 Share Posted June 4, 2013 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.." Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted June 4, 2013 Share Posted June 4, 2013 Use "self.Components..." or just "Components..." instead of "UniFrame3.Components...". And never use a global var, because each user/session would use the same var. If needed use fields / properties. Quote Link to comment Share on other sites More sharing options...
Jean-Marc Kiener Posted May 30, 2016 Share Posted May 30, 2016 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? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 30, 2016 Administrators Share Posted May 30, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.