SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Slick-C® Macro Programming => Topic started by: Sasha on March 10, 2007, 03:25:27 pm

Title: Main Menu Changes
Post by: Sasha on March 10, 2007, 03:25:27 pm
Hi All,

I have troubles with changing of SlickEdit Menu.
I am trying to configure Version Control (we use Clear Case). I would like to change some names of the options, for example change ‘Add’ to ‘Make Element’ since the default names  are not associated with the actions for Clear Case users. As I understood from the help pages it can be done using Macro-->Menus dialog. I choose ‘_vc_menu’ and open it. After it I change the Caption and click OK. I see my changes when I click on ‘Show’ button, but I didn’t find a way how to load my changes to the main menu. When I open Tools-->Version Control the menu is showed as it was before my changes. I tried different ways to configure it but without success. The changes are stored in vslick.stu file in my home dir, so it seems like nothing should be loaded. After deep investigation I found that sysobjs.e located in the central installation directory is responsible for menu changing. After hacking of this file (changing of ‘Add’ to ‘Make Element’ in 3 different places of code) I succeeded to see the changes in my main menu. Is there any more correct/elegant way to change the caption in menu, add/remove menu item? It looks like the options described in the help: Slick-C Macro Programming Guide > Menus don’t work for me as well.

Thanks in advance,
Title: Re: Main Menu Changes
Post by: Matthew on March 14, 2007, 01:57:35 pm
From the Macro > Menus... command, select "_mdi_menu" from the listing. In the resulting tree view menu editor you can expand down to the Tools > Version control submenu.
Title: Re: Main Menu Changes
Post by: Bandersnatch on April 19, 2007, 07:09:49 pm
Hey there,

I have a related question and I didn't want to start a new topic and clutter the board.  I'm trying to make a macro that automatically adds another menu item in the mdi menu, but I'm having trouble getting it to place a value in the submenus.  That is, it's easy to add to the mdi bar, but I want to get a function in the Projects tab.  I've looked through menu.e, and searching the help but I can't find any particular function beyond _menu_insert, which seems to only allow me to add to the mdi bar, as noted before.

Any help would be greatly appreciated.
Title: Re: Main Menu Changes
Post by: GregA on October 18, 2007, 03:16:30 am
From the Macro > Menus... command, select "_mdi_menu" from the listing. In the resulting tree view menu editor you can expand down to the Tools > Version control submenu.

I'm doing something like this but would like to realize the menu change without needing to restart SlickEdit. How can I do that? When I set def_mdi_menu = [new mdi menu] in either defload() or definit() and Load that macro file, I still don't see any change in the menu until I restart SlickEdit.

As a result, I currently do an automatic restart - but it's not something I'm happy about.
Title: Re: Main Menu Changes
Post by: GregA on February 28, 2008, 06:40:20 pm
Here I am again, replying to my own post but have new material too.

I found a way to bypass the restart. Given that I wasn't able to get _menu_insert() to insert a new top level menu item into the (main) MDI menu, I was surprised to find more recently that _menu_set() does produce a menu update without the need to restart SlickEdit. And to give credit, how to do this is more or less detailed in one or more SlickEdit Help examples. My working code is:

   def_mdi_menu = 'my_mdi_menu';
   int index = find_index (def_mdi_menu, oi2type(OI_MENU));
   int menu_handle = _menu_load (index);
   int old_menu_handle = _mdi.p_menu_handle;
   _mdi._menu_set (menu_handle);
   if (old_menu_handle) {
       _menu_destroy (old_menu_handle);  /* or should that be _mdi._menu_destroy, I wonder? */

As it should be. But where do I get my menu content? I copy the _mdi_menu resource text from macros/sysobjs.e and insert into it, at the right point, the text block of my new menu item. A little more magic and - voila! Now, even without restarting.

BUT, BUT, enter the SlickEdit v13 beta. NO SYSOBJS.E! Yes, sysobjs.ex, but no text ... no my_mdi_menu. The sysobjs.e omission  may be intentional and may even be a good idea but it forced upon me an even greater task. I now also include logic to traverse the MDI menu using _menu_get_state(), essentially reverse-engineering the whole thing. I'm now trying to free myself of a remaining bug.

I realize that I'm apt to be blown out of the water here but my question is this: Wouldn't it be reasonable to alter _menu_insert() so that a poor sod like myself can execute the simple task of inserting a new top-level menu into the main MDI menu in a way that is, well, simple?
Title: Re: Main Menu Changes
Post by: ScottW, VP of Dev on February 29, 2008, 07:23:51 pm
@GregA: I'm really struggling to follow this thread. Are you saying we aren't shipping sysobjs.e? I see it on my Windows install.

The rest seems to be a request for how to modify the main menu. Is that correct?
Title: Re: Main Menu Changes
Post by: GregA on March 01, 2008, 01:53:19 am
Hello Scott,

You're right about sysobjs.e. I've just extracted the Beta 1 distribution using LesMSIerables and sysobjs.e is there. It's just not in my installation!

First, I must retract my glowing red words above, mustn't I? Second, why would I be missing sysobjs.e? I must have somehow deleted it soon after installation. More than finger trouble, that.

So, I have 2 variant techniques for effecting a top level MDI menu change, one '100%' and the other just about there. But as I seem to have stolen your attention: yes, isn't there an easier way to make this kind of change to the MDI menu - a simple use of _menu_insert(), for example? See image.


Title: Re: Main Menu Changes
Post by: ScottW, VP of Dev on March 03, 2008, 02:24:36 pm
The image isn't visible. I assume you've posted a sample that shows how you think this kind of interrface should work. If not, please do so. Some areas of the Slick-C API lack the abstraction that would make some of these kinds of tasks simple. If this is one, then perhaps we could fix that.
Title: Re: Main Menu Changes
Post by: Phil Barila on March 03, 2008, 05:53:30 pm
I don't have a dog in this fight, but the image was visible for me.
Title: Re: Main Menu Changes
Post by: ScottW, VP of Dev on March 03, 2008, 08:37:55 pm
OK, now I see the picture. Until Phil could see it, I wasn't really willing to believe it was there, I guess.  ;D

I'll check with the team to see how you might add that kind of menu item. Maybe there is an easier method.
Title: Re: Main Menu Changes
Post by: Rodney on March 11, 2008, 05:11:13 pm
Modifying a menu resource and then swapping it in (which is what GregA is doing with _menu_set) is really the only good way I know to add a top-level menu to the MDI menu bar programatically.

I have attached a small sample that demonstrates adding a top-level menu (along with items and submenu) to the MDI menu bar. It makes use of _load_mdi_menu() which is what we use when initializing the editor, so you can use that instead. The sample also demonstrates how to make the change permanent if you choose. There are lots of comments, so please read them.

A note: Some APIs like _menu_insert can operate on an active menu handle and also on a menu resource index. Do not get the two confused.

If you are interested in diving more deeply into things, then I suggest you trace the menu editor code (_menu_editor_form).

Good luck.