Jump to content

What To Put In Area A?


Frederick

Recommended Posts

As I click the menu items in the tree menu, what control(s) should I put in Area A so that a different TUniDBGrid is shown.

Since each TUniDBGrid uses a different query, should I open and close the query as the grid is shown and hidden or should I open all queries at the start of the program. I am thinking in the interest of memory usage.

Area A is currently a TUniContainerPanel.

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1558)
 

Link to comment
Share on other sites

22 minutes ago, Frederick said:

As I click the menu items in the tree menu, what control(s) should I put in Area A so that a different TUniDBGrid is shown.

Since each TUniDBGrid uses a different query, should I open and close the query as the grid is shown and hidden or should I open all queries at the start of the program. I am thinking in the interest of memory usage.

Area A is currently a TUniContainerPanel.

Hello,

Well, it all depends on the task (by the count of data displayed) I think...

 

Link to comment
Share on other sites

hi Frederick,

Put unicontainer, panel or pagecontrol on area A, then embed a form or aframe, use create an release's technique to reduce memory usage.  

for example like this :

AForm := TUniForm1.Create(UniSession.uniApplication)
AForm.parent := unicontainer1;

AFrame := TUniForm1.Create(MainForm)
AFrame.parent := panel1; //uniTabsheet1;
 

Link to comment
Share on other sites

Hi Point,

I plan to use a pagecontrol in area A and create individual forms containing grids.

Can I assign an existing form's parent to the pagecontrol's tabsheet when a menu item in the tree menu is selected and then set the form's parent to NIL when another menu is selected? Will this method reduce memory use?

Link to comment
Share on other sites

I am not sure what I am doing wrong but the forms are not displaying inside the TUniTabSheet of the TUniPageControl.

I have two application forms and my code when each TUniMenuItem is clicked is:-

procedure TMainForm.mnu1Click(Sender: TObject);
var
   cMenu : String;
begin
   cMenu:=treMenu.SourceMenu.Items[treMenu.Selected.Id].Name;
   if assigned(oForm) then
      oForm.Close;
   oForm:=NIL;
   if cMenu='mnu1' then begin
      oForm:=frmForm1;
     end
   else if cMenu='mnu2' then begin
      oForm:=frmForm2;
   end;
   if assigned(oForm) then
      oForm.Parent:=tab1;
end;

However, the application forms are displayed outside the main form. What could be the problem?

Link to comment
Share on other sites

1 hour ago, Frederick said:

I am not sure what I am doing wrong but the forms are not displaying inside the TUniTabSheet of the TUniPageControl.

I have two application forms and my code when each TUniMenuItem is clicked is:-

procedure TMainForm.mnu1Click(Sender: TObject);
var
   cMenu : String;
begin
   cMenu:=treMenu.SourceMenu.Items[treMenu.Selected.Id].Name;
   if assigned(oForm) then
      oForm.Close;
   oForm:=NIL;
   if cMenu='mnu1' then begin
      oForm:=frmForm1;
     end
   else if cMenu='mnu2' then begin
      oForm:=frmForm2;
   end;
   if assigned(oForm) then
      oForm.Parent:=tab1;
end;

However, the application forms are displayed outside the main form. What could be the problem?

you must create a form like i wrote above.

here the clue :

1. use free form

2. global variable for a form (must thread safe variable)

3. release form's variable when you load another form

4. pure OOP, to avoid memory leak. use override and virtual method

 

 

Link to comment
Share on other sites

I created two free forms giving them each a name of frmFree1 and frmFree2 respectively.

   if cMenu='mnu1' then begin
      oForm:=frmFree1;  // Compiler chokes here and says "Undeclared Identifier frmFree1"
     end
   else if cMenu='mnu2' then begin
      oForm:=frmFree2;  // Compiler chokes here and says "Undeclared Identifier frmFree2"
   end;

even when the units for the two forms are in the Uses clause.

I can't create the free form dynamically because I need to design the form itself with controls and components there.

I'll need to research further since I have never used free forms in UniGUI before.

Link to comment
Share on other sites

On 3/3/2022 at 12:04 PM, Point said:

hi Frederick,

Put unicontainer, panel or pagecontrol on area A, then embed a form or aframe, use create an release's technique to reduce memory usage.  

for example like this :

AForm := TUniForm1.Create(UniSession.uniApplication)
AForm.parent := unicontainer1;

AFrame := TUniForm1.Create(MainForm)
AFrame.parent := panel1; //uniTabsheet1;
 

 

corrected :

AFrame := TUniFrame1.Create(MainForm)
AFrame.parent := panel1; //uniTabsheet1; 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...