Q: API Menu Callback...
We re writing an application in VB5 Enterprise. We d like to keep it generic, object oriented and data-driven. One of our problem is MENU. Our application will define user s access rights for each form, control and menu item. But it forces us to have menu-structure definition kept on two places :
1) menu is created by VB MenuEditor and its structure (definition) is stored in FRM file and after COMPILE is stored in EXE file.
2) we have to have menu-structure definition stored also in our database to be able to assign users rights to menu items.
It can cause a dangerous inconsistency between these two instances of menu definition. It is also difficult for developers to maintain two copies of menu : to add a menu item in VB MenuEditor, then go to our application and add this menu item (and its access rights) to our tables.
What would I imagine as an elegant solution : To have whole menu structure stored in our tables (and create suitable maintenance tool) and dynamically build the menu on application s startup. (I can imagine beautiful menu-editing tool based on treeView control )
Is this possible using just standard VB commands ? I don t think so. I m not too familiar with the 32bit API (to be honest with no API at all ), but I expect that it ought to be able to do this work for me. But how ?
And even if I would create that menu dynamically by some API calls, how to then tell my app, which menu-item was selected. Could it be done with some callback technique ?
Lukas Casar, casar@integia.cz

A: The simpliest way is to make the whole menu-structure in VB code. I do this also. When starting the application I check the username against a database which gives a status-code for that user. On the mainform load event I then set the proper menu-items to visible/invisible (or enabled) depending on the status-code. No API call's involved but it depends on how big you application and the menu are how 'fast' it will be... You can do this setting of menu-items on one place for all the forms! So you don't have to do it every time you start/open another form; only when you first start the application. I hope it will help you.. Return