Freeman35 Posted August 28, 2018 Share Posted August 28, 2018 How to use inherited MainForm ? I made MainForm, I added allcode what I need. My plan is, when make new project, I'll make inherited main form from T_FRM_Ced, and just add TUniMenuItem on inherited form so I'll not write or copy all other codes. Problem is, When run project, I get this error: An Exception has occured in application: Access violation at address 0040A194 in module 'project_wan.exe'. Read of address 00000000 Restart application Type TFRM_Main = class(T_FRM_Ced)// My master mainform MNU_x: TUniMenuItem; private { Private declarations } public { Public declarations } end; function FRM_Main: TFRM_Main; implementation {$R *.dfm} uses uniGUIVars, _uDM_rukn, uniGUIApplication, _uDM_Server; function FRM_Main: TFRM_Main; begin Result := TFRM_Main(_DM_rukn.GetFormInstance(TFRM_Main)); end; initialization RegisterAppFormClass(TFRM_Main); // RegisterMainFormClass(TFRM_Main); end. Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 28, 2018 Author Share Posted August 28, 2018 Found problem. Form has TUniMenuItems, error created while TReader Imean while reading form resourse. I cut (ctrl + x) TUniMenuItems and save file, then paste (ctrl + v) TUniMenuItems, then save again, build project and run. Error gone Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 30, 2018 Author Share Posted August 30, 2018 I attach test case. You can see child_MainForm's "MNU_Items" has "MNU_x1" This Item added on child_MainForm. and some Items comes from master mainform. If you run this project you will see acces voişation error. Whem remove MNU_x1 child_MainForm, then run again, project work normal. What is wrong on this project? Thank you Fatal-Error.7z Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 Type TFRM_Main = class(T_FRM_Ced)// My master mainform MNU_x: TUniMenuItem; private { Private declarations } public { Public declarations } end; function FRM_Main: TFRM_Main; implementation {$R *.dfm} uses uniGUIVars, _uDM_rukn, uniGUIApplication, _uDM_Server; function FRM_Main: TFRM_Main; begin Result := TFRM_Main(_DM_rukn.GetFormInstance(TFRM_Main)); end; initialization RegisterAppFormClass(TFRM_Main); // RegisterMainFormClass(TFRM_Main); end. Would you mind telling us how did you create the inherited child? Manually? It should be done from uniGUI Wizard. Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 30, 2018 Author Share Posted August 30, 2018 Because, statics code on "T_FRM_Ced" Menu settings for users, some infos etc. I'm planing move a few applicaiton to web. Why I have to copy all codes to each application? for example, a few time later found bug in code or make upgrade, why I have to do this all projects? modify one file and just build other project so stabil & fast way. This inhrited is classic pascal style. And not hard code in master form. We talked before. MainModule is okey I can not inherited it, it has unigui codes, thread etc. But mainform not be like that? On my test case, has just TUniMenuItems and Items thas all, no any code no any JS code Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 30, 2018 Author Share Posted August 30, 2018 Same project, same way. Just add normal form and inherited form. Main form has two button. first one open normal form, second button open inherited form. Inherited form has added "MNU_y1: TUniMenuItem;" I think this mean not just for mainform problem, tuniform problem. Fatal-Error-2.7z Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 Because, statics code on "T_FRM_Ced" Menu settings for users, some infos etc. I'm planing move a few applicaiton to web. Why I have to copy all codes to each application? for example, a few time later found bug in code or make upgrade, why I have to do this all projects? modify one file and just build other project so stabil & fast way. This inhrited is classic pascal style. And not hard code in master form. We talked before. MainModule is okey I can not inherited it, it has unigui codes, thread etc. But mainform not be like that? On my test case, has just TUniMenuItems and Items thas all, no any code no any JS code I am telling the way you created the child form wrong. You must inherit using uniGUI Wizard: File->New->Other-UniGUI->Inheritable Items Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 Same project, same way. Just add normal form and inherited form. Main form has two button. first one open normal form, second button open inherited form. Inherited form has added "MNU_y1: TUniMenuItem;" I think this mean not just for mainform problem, tuniform problem. In MainForm you've manually commented the most important part of the unit: //initialization // RegisterAppFormClass(TMainForm); And you still expect it to work? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 Same project, same way. Just add normal form and inherited form. Main form has two button. first one open normal form, second button open inherited form. Inherited form has added "MNU_y1: TUniMenuItem;" I think this mean not just for mainform problem, tuniform problem. You are registering the inherited child form as application MainForm. Of course, it will fail. initialization RegisterAppFormClass(TChild_MainForm); Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 30, 2018 Author Share Posted August 30, 2018 I'm lazy so ofcourse use wizard. Yes, I'll manually remark that registerline, I wanna make mainform TChild_MainForm, but inherited from TMainForm ( type TChild_MainForm = class(TMainForm) ) Can you sent this codes? or test case, I can not do this Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 I'm lazy so ofcourse use wizard. If you had used the wizard, it would have done it correctly. Please try again from the beginning and use uniGUI wizard for creating inherited forms. Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted August 30, 2018 Author Share Posted August 30, 2018 I did Farshad,For your suggestion I did one more time. Please follow Project4. when run application, can you see red colored label on mainForm ? I wanna see this. And main problem is access voilation error... Project4.7z Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 In child unit: Here is the mistake. You are registering MainForm twice. initialization RegisterMainFormClass(TMainForm); end. It must be: initialization RegisterMainFormClass(TMainForm_Inherited); end. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 In MainForm unregister original MainForm: initialization // RegisterAppFormClass(TMainForm); Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 30, 2018 Administrators Share Posted August 30, 2018 Issue is resolved I think, but this is not recommended. Instead, use inherited frames embedded in Mainform. Quote Link to comment Share on other sites More sharing options...
DonaldShimoda Posted October 16, 2019 Share Posted October 16, 2019 Seems like inherited wizard fails with message Frame not found. Can please fix? Quote Link to comment Share on other sites More sharing options...
DonaldShimoda Posted October 16, 2019 Share Posted October 16, 2019 On 8/30/2018 at 6:47 AM, Farshad Mohajeri said: Issue is resolved I think, but this is not recommended. Instead, use inherited frames embedded in Mainform. Any reason for this? I having issues right now. base form have a TUniMenuItems. Add a item to the inherited form and raise AV, remove the item the AV is gone... 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.