On Dec 18, 2017, at 2:00 PM, Jeremy Roussak wrote: > Your last line is the key: according to the documentation, nothing has > changed, but when I run the code, everything has changed. > > So it seems that if I want to have component display a form while keeping the > host’s menus visible and working, I must create all the host’s menus using > code rather than using the toolbox Menu editor. > > Can that really be right?
I’ve done some work with components that have forms and their own menu bar. It is a tricky area for sure. One problem I ran into was from the component I wanted to open a window, use DIALOG command and to have a custom menu bar for this new window. So from the host I would start a new process and then call a component method that would do this work. This is running in a new process, but the method “ShowEditor” is from the component and it is of course shared so it can be called fro the host. Here is sample code: SET MENU BAR(“Editor Menu”) OPEN WINDOW DIALOG This worked fine form some host database, but other it didn’t work. The menu bar was screwed up. I finally figured out what was going and how to fix it. The problem was SET MENU BAR command using a menu bar name for a menu created in Design in the Toolbox. Even though I was referencing it by name it was still internally somehow referencing the menu bar number. So if the host had a menu bar with the same number “Editor Menu” in the component database there were problems. One workaround was to create many many dummy menu bars in the component from the Toolbox. I needed to get the menu bar number high enough so it would not have a conflict with any menu bars in the host database. That worked, but was a big pain-in-the-ass because I use a lot of menu bars in my applications and all created with the Toolbox. So I had to create like 50 blank menu bars in the component to make this work. Then I got the idea to do this: C_TEXT($menuRef_t) $menuRef_t:=Create menu(“Editor Menu") SET MENU BAR($menuRef_t) Problem solved. No need to create dummy menu bars in the component. So maybe you could use this technique for your application. Create the menu in the host and get a $menuRef_t. Then pass $menuRef_t to your component. From the component context you do SET MENU BAR($menuRef_t). I think $menuRef_t is sort of like a pointer or a memory location reference. So that would allow you to share a menubar from the host, created in the toolbox, with a component. Tim ******************************************** Tim Nevels Innovative Solutions 785-749-3444 [email protected] ******************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

