chefdackel Posted October 20, 2014 Share Posted October 20, 2014 Starting a new project with UniGui I want to be sure to understand the main aspects of GUI design with UniGUI. Please correct me if there is something wrong with these statements or if there is general better design of some facts. Thank you! ========================== 1. If possible avoid the use of free forms - because they are not framework controlled and the use of variables, (unigui-)controls etc. in these forms are not thread safe.========================== 2. When using an unigui wizzard created application form, the framework controls the thread safe use of variables, (unigui-)controls etc which are part of this application form. So when defining a "myvar"variable in the public part of the application form class, this variable can be accessed around the session which creates the application form, and no further attention has to be turned on shielding it from other sessions. ========================= 3. Not every third party control which is used in application forms is automatically thread safe - if the control itself is not designed in this matter, there may be problems when using them in an internet application. An example may be printing tools/controls. ========================== 4. Because application forms are instances of UniMainModule, every session which creates this form has its own instance of the form, f.e.: function Form_Upload1: TForm_Upload1;begin Result := TForm_Upload1(UniMainModule.GetFormInstance(TForm_Upload1));end; ========================== 5. Data access components are to be placed in UniMainModule or a Datamodule which is created with the UniGui wizzard, so this Datamodule has also to be an instance of UniMainModule. ========================== 6. For data access its ok to put the grid, the query and the datasource on an application form, only the database connection component itself has to placed on the UniMainModule or UniMainmodule controlled Datamodule. ========================== 7. Application forms never have to be created manually. As soon as something on the application form is accessed UniGui will create the form. So when I want to init some data access on the application form its ok to build a procedure "OpenData" in the application form (assuming query and datsource are on the application form). When calling myAppForm.OpenData f.e. from the MainForm the application form will be created from UniGui and can be shown with myAppForm.show:procedure TmyAppForm.OpenDatabegin Query1.open; Query2.open; Query3.open;end;The best place to clean up data access then is in the OnClose event of the application form:procedure TmyAppForm.OnClosebegin Query1.close; Query2.close; Query3.close;end; ========================== 8. When closing the application form with myAppForm.close the form and the ressources are freed UniGui controlled. ========================== 9. It is ok to use some kind of "global variables" as long they are defined in the UniMainModule. So every session has its own set of these (session-)global variables. ========================== 10. I have a GUI model where in the mainform there are the buttons "customer" and "product". When I click on the "customer"-button, an application form is created. On this application form I have a panel which is the parent of different frames. When first displayed there is a "list"-frame created with a grid which lists the customers. When I want to edit a specific record, I close the "list"-frame and create a "detail"-frame where the detail data can be edited. After posting the data the "detail"-frame is closed and the "list"-frame is created again. Data access components grid, query and datasource for the grid are on the "list"-frame, data access components query and datasource for the data edit components are on the "detail"-frame. They use the same data connection component on the Datamodule. On every creation of a frame I open the queries, when closing a frame I close the queries. The question is: because of using frames (with the panel parent on an application form) and the described data access, is this model still recommended and thread safe? brfc 3 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.