Jump to content

accessing Frame from the Main form


Phxtecno

Recommended Posts

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

Link to comment
Share on other sites

  • Administrators

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

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...