Phxtecno Posted December 12, 2015 Share Posted December 12, 2015 Hi, I have an application with structure like the UniGui DEMO, with a Main form and many Frames loaded at runtime as TUniTabSheet. In the Main form when I need call methods which reside in the uniMainModule, for example open a table, I can use this sintax: uniMainModule.tabCustomers.Open; because using the suggested declaration in MainModule: function uniMainModule: TuniMainModule;begin Result := TuniMainModule(UniApplication.UniMainModule)end; Now I try to do the same things for a Table available on my Frames, but getting exceptions at runtime because of wrong declaration I guess... Can you help on this different declaration/sintax ? Regards, Marc Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 12, 2015 Administrators Share Posted December 12, 2015 What is your syntax? Quote Link to comment Share on other sites More sharing options...
Phxtecno Posted December 12, 2015 Author Share Posted December 12, 2015 Hi, on my Frame fraDevices I have added: function fraDevices: TfraDevices;begin Result := TfraDevices(UniApplication.fraDevices);end; and from my Main form I try to do fraDevices.tabCars.Open; Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 12, 2015 Administrators Share Posted December 12, 2015 Unlike Forms and Modules, Frame instances are not managed by uniGUI, so above syntax will not work. Frames are like other ordinary objects such as Panels, Buttons and etc. A frame has an instance only when it is placed on a parent or created manually in code. I also think you have a basic design problem. Why do you want to access something that belongs to a Frame from another object? Quote Link to comment Share on other sites More sharing options...
Phxtecno Posted December 12, 2015 Author Share Posted December 12, 2015 I create the Frame instance manually by code, the same as you do in your demo, and it works. In your demo you use Frames like pseudo mdi-forms and I am doing the same in my application, because I feel it efficient. The different thing is that I have a treeview in my Main which in some situations I need syncronize with DbGrid present on some Frames; I need pass the current item to let the frame syncronize. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 12, 2015 Administrators Share Posted December 12, 2015 I understand. Grids are automatically synchronized when dataset changes. If you need to access Frames directly then you must keep a dynamic list of them in a TList declared in uniMainModule. Quote Link to comment Share on other sites More sharing options...
Phxtecno Posted December 12, 2015 Author Share Posted December 12, 2015 Could you show me the sintax to save Frame reference in a TList and how to access them from MainForm to use them later ? in my MainForm current code I do this: for i := 0 to UniPageControl1.PageCount - 1 do begin // search the frame if UniPageControl1.Pages.Name = 'TfraDevices' then begin //found the right frame if UniPageControl1.ActivePage = TUniTabSheet(UniPageControl1.Pages) then begin //if it's active, do syncronize key := tvWardsLayout.Selected.Item[0].Text; fraDevices.tabDevices.Locate('ID', key, []); end; end; end;//for Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 12, 2015 Administrators Share Posted December 12, 2015 Easy method is to give a unique name to your frames and then call YourForm.FindComponent('FrameName') to find your frames. 1 Quote Link to comment Share on other sites More sharing options...
Phxtecno Posted December 12, 2015 Author Share Posted December 12, 2015 Thank you ! 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.