Hi All
I thought I would share this with the community in case someone else might benefit from it. After reading Peter Greulich�s post about a tree menu system he has created and Bob McGraffic�s excellent post in the code archive about how to use an activex control for creating a tree menu system, I decided to try and create my own using the embedded Xdialog Supercontrol in v9. The tree control used in the xdialog allows the use of open and closed icons (something the regular form tree control cannot do). The result of my tinkering is what you see here.
Attached are some screen shots as well as the zipped database.
Items of note:
1. The TreeMenuForm form shows the embedded xdialog. The menu shown is set by a global variable called gvuser in the autoexec script. In my normal apps I have a login routine that sets this variable.
2. You can test the dynamic nature of the menu by closing the TreeMenuForm and opening the DynMenuBrws_frm and changing the �Allowf� choice from the one that is �F� (false) to true for terir. Now open the TreeMenuForm again and you will see that menu item.
3. There is a �master menu table� that is the template for all new menus as well as to update the menus that were previously created.
4. There is a button on the DynMenuBrws_frm to add a new menu for a user. When prompted enter the userid for the new user and a new menu system will be created for them. You can then use the dropdown to filter the browse to edit the menu choices for that user. Remember: if you want to see that menu then you need to set the value of gvuser to the new userid you just created .
5. There is another button on the DynMenuBrws_frm that will let you update the menu for the user you are viewing in the likely event you make a change to the �Master Menu� table and now want those menu items over in the Dynamic Menu table.
6. You will notice that the icons (see screenshot) for all the administrative level are the same. This is VERY important to get the tree to show correctly. Since the tree Xdialog is built from a string � the string value at this top menu level must be the same if you want one entry for �Administrative�. If you were to have different open and close icons for each entry for this level then the tree shows a branch for each of those because it needs a place to display the different open and closed icons. When they are the same then the tree shows them under one branch as you would expect
7. The menu system framework I have created is 3 levels deep.
8. The icons you see in the DynMenuBrws_frm form are embedded in the table for easy showing in the browse � this aids in setup. I know this is not �Best Practice� but for this use I think it is fine since there will be relatively a small number of icons. You will notice I also store the filename of the icon for each choice. This text is used in the creation xdialog tree string.
9. Each menu item has control panel name and type. This tells the menu what to do with the choice if the user selects it. Pay no attention to what runs when you select the item � they are not what the items say � they are just for testing.
10. The icons I have chosen are gotten to when you use the edit button on the DynMenuBrws_frm. You can see you will be presented with the dialog box letting you choose from the internal images (or image from your own library you attach to this database).
11. There is not much error checking or polish with this example because everyone�s implementation is likely to be different but there is a solid core I believe to making your own dynamic menu system that is appealing to the eye.
12. Always start form the highest level and go down. For example, do not enter level one information and then no level 2 information � but then you enter level 3 information for a menu item
13. You DO NOT have to enter an open and closed icon for each menu choice. If you only want one icon for a menu choice then just add a �Closed Icon� for that level. The code will take care of showing the tree properly. This would be common if you did not have 3 levels and the 2nd level was the actual menu choice � obviously you don�t need an opened icon since once you click on it you will be going to the form or report you chose.
I am probably forgetting something�.hope not�..I hope this is useful for the Alpha Community.
Regards,
Jeff
I thought I would share this with the community in case someone else might benefit from it. After reading Peter Greulich�s post about a tree menu system he has created and Bob McGraffic�s excellent post in the code archive about how to use an activex control for creating a tree menu system, I decided to try and create my own using the embedded Xdialog Supercontrol in v9. The tree control used in the xdialog allows the use of open and closed icons (something the regular form tree control cannot do). The result of my tinkering is what you see here.
Attached are some screen shots as well as the zipped database.
Items of note:
1. The TreeMenuForm form shows the embedded xdialog. The menu shown is set by a global variable called gvuser in the autoexec script. In my normal apps I have a login routine that sets this variable.
2. You can test the dynamic nature of the menu by closing the TreeMenuForm and opening the DynMenuBrws_frm and changing the �Allowf� choice from the one that is �F� (false) to true for terir. Now open the TreeMenuForm again and you will see that menu item.
3. There is a �master menu table� that is the template for all new menus as well as to update the menus that were previously created.
4. There is a button on the DynMenuBrws_frm to add a new menu for a user. When prompted enter the userid for the new user and a new menu system will be created for them. You can then use the dropdown to filter the browse to edit the menu choices for that user. Remember: if you want to see that menu then you need to set the value of gvuser to the new userid you just created .
5. There is another button on the DynMenuBrws_frm that will let you update the menu for the user you are viewing in the likely event you make a change to the �Master Menu� table and now want those menu items over in the Dynamic Menu table.
6. You will notice that the icons (see screenshot) for all the administrative level are the same. This is VERY important to get the tree to show correctly. Since the tree Xdialog is built from a string � the string value at this top menu level must be the same if you want one entry for �Administrative�. If you were to have different open and close icons for each entry for this level then the tree shows a branch for each of those because it needs a place to display the different open and closed icons. When they are the same then the tree shows them under one branch as you would expect
7. The menu system framework I have created is 3 levels deep.
8. The icons you see in the DynMenuBrws_frm form are embedded in the table for easy showing in the browse � this aids in setup. I know this is not �Best Practice� but for this use I think it is fine since there will be relatively a small number of icons. You will notice I also store the filename of the icon for each choice. This text is used in the creation xdialog tree string.
9. Each menu item has control panel name and type. This tells the menu what to do with the choice if the user selects it. Pay no attention to what runs when you select the item � they are not what the items say � they are just for testing.
10. The icons I have chosen are gotten to when you use the edit button on the DynMenuBrws_frm. You can see you will be presented with the dialog box letting you choose from the internal images (or image from your own library you attach to this database).
11. There is not much error checking or polish with this example because everyone�s implementation is likely to be different but there is a solid core I believe to making your own dynamic menu system that is appealing to the eye.
12. Always start form the highest level and go down. For example, do not enter level one information and then no level 2 information � but then you enter level 3 information for a menu item
13. You DO NOT have to enter an open and closed icon for each menu choice. If you only want one icon for a menu choice then just add a �Closed Icon� for that level. The code will take care of showing the tree properly. This would be common if you did not have 3 levels and the 2nd level was the actual menu choice � obviously you don�t need an opened icon since once you click on it you will be going to the form or report you chose.
I am probably forgetting something�.hope not�..I hope this is useful for the Alpha Community.
Regards,
Jeff
Comment