sagt3k Posted April 27, 2012 Posted April 27, 2012 Hi I would assign an TNotifyEvent object to another object T1.OnClick: = T2.OnClick; T2.Onclick = TNotifyEvent is created directly on the program, and T1.OnClick is null, I would assign OnClick T2 to T1 or other events, but apparently does not work at RunTime T1.Onclick after I press the menu web T1. How can I fix this? Thanks Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Test case please. Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 Test case: //T2 is created on MainMenu, and UniButton3 on MainForm procedure TMainForm.T2Click(Sender: TObject); begin UniApplication.Terminate('') end; procedure TMainForm.UniButton3Click(Sender: TObject); Var T:TUniMenuItem; Begin T:=TUniMenuItem.Create(UniApplication); T.FreeOnRelease; T.Name:='T1'; MainMenu.Items.Add(T); T.OnClick:=T2.OnClick; T.Visible:=True; T.Enabled:=True; T.Caption:='T1'; end; The problem is that T1 is created at runtime, it does not work when pressed. In practice I have to create a dynamic menu at run time and assign events at runtime. Thanks in advance for your support. Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 First problem I see is that MenuItem owner must be a Form. T:=TUniMenuItem.Create(UniApplication); Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 T:=TUniMenuItem.Create(ApplMainForm); OK I replaced, but it does not work the same. A doubt, but the main form when they are in 'vcl_session' or the web session is always 'ApplMainForm' ? Where ApplMainForm is assigned as : TApplMainForm = class(TUniForm) .... function ApplMainForm: TApplMainForm; .... Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 What is ApplMainForm? We don't have such a default Form. procedure TMainForm.UniButton3Click(Sender: TObject); Var T:TUniMenuItem; Begin T:=TUniMenuItem.Create(Self); <------------------------------ end; Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 We have a bug here. Logged #1328 Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 ApplMainForm is the name of my main Form. ImageIndex would still appear to have a problem. Thanks for the resolution of bugs. I think, for us developers unigui is the final solution of web applications for Delphi. So also in our interest to help develop it. Thanks Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Workaround: procedure TMainForm.UniButton1Click(Sender: TObject); Var T:TUniMenuItem; Begin T:=TUniMenuItem.Create(Self); T.FreeOnRelease; T.Name:='T1'; T.OnClick:=Test1.OnClick; T.Caption:='T1'; UniMainMenu1.Items.Add(T); // call add here end; Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 Hey ... thanks works great! It seems that you still know your secrets! But given that I have at the same time and in the same form to load different menus, how can I reset the menu and bring it to reset? Not enough to do. Free and recreate it (MainMenu)? Could you help me? Thanks !!! Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 I use this code to reset mainmenu in 'vcl_session' works fine: For I: = 0 to MainMenu.Items.Count-1 do MainMenu.Items .Clear; MainMenu.Items.Clear; but 'web_session' no. How do I can reset mainmenu? Thanks Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 For I:= 0 to UniMainMenu1.Items.Count-1 do UniMainMenu1.Items[i].Free; Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 It does not work !! in 'vcl_session' thenlast menu item is visible and in 'web_session' appears this error 'List index out of bounds (1)' Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Please send a test case then. It works here. Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Try this: For I:= UniMainMenu1.Items.Count-1 downto 0 do UniMainMenu1.Items[i].Free; Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Haven't u tried this: UniMainMenu1.Items.Clear; Quite easy! Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 Yes , I have tried it... however, in attached the project, in vcl_session it's OK, but in web_session does not work !!! For me it is very important to convert a large project with unigui, and change the menu depending on the user profile is vital !! Thanks Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 with the attached file is better ... unisample.zip Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 with the attached file is better ... Your project doesn't contain PAS files. Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Why don't you simply start a new Form and create all menu items instead of modifying same menu of same form? Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 Sorry about before, now attached the complete project. Let me explain, I developed a big management software in delphi and I would make the project a web. UniGui is perfect. So, I have a database where I created the tables PROFILE, USER, and MENU. Can I assign profiles to the USER and PROFILE MENU. In real time, while the user is working, the software is to analyze the profile and in the case is to add or remove menu items without having to shut down or restart the MainForm. It would be possible to change the database and edit the menu in real time, of course, any form or by closing the open frame. uniguimenu.zip Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Your test case works perfectly here. Are you using latest uniGUI build? Quote
sagt3k Posted April 27, 2012 Author Posted April 27, 2012 No I'm using version 0.87 with DELPHI XE2 never update. The problem is that I'm working with a PC that is not my office and have not done the updates of DELPHI XE2, so I can't install version 0.88 because of the need to update. Personally I have my licensed version of Delphi 7, but UNIGUI not work with this Anyway, now I know why it did not work. Thanks, thanks you. Quote
Administrators Farshad Mohajeri Posted April 27, 2012 Administrators Posted April 27, 2012 Tons of bugs are fixed since 0.87.0 Quote
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.