• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Adding FSX menus in C#

Hey Ralph,

You should be able to follow the C++ example of the menu items.

Set up the events for the menu events, set up a group for these menu items.

Code:
                // Create some private events
                simconnect.MapClientEventToSimEvent(EVENTS.MENU_ONE,"");
                simconnect.MapClientEventToSimEvent(EVENTS.MENU_TWO, "");

                // Add one menu item
                simconnect.MenuAddItem("Menu Item One", EVENTS.MENU_ONE, 12345);

                // Sign up for the notifications
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_ONE, false);

                simconnect.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP_MENU, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);

Then add in the receive event processing.

Code:
                case (uint)EVENTS.MENU_ONE:
                    this.Text = "Menu item one selected %d" + recEvent.dwData.ToString();

                    ++menuUseCount;

                    // Selected four times, so replace item one with item two
                    if (menuUseCount == 4)
                    {
                        simconnect.MenuDeleteItem(EVENTS.MENU_ONE);
                        simconnect.RemoveClientEvent(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_ONE);

                        simconnect.MenuAddItem("Menu Item Two", EVENTS.MENU_TWO, 54321);
                        simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_TWO, false);
                    }
                    break;

                case (uint)EVENTS.MENU_TWO:

                    ++menuUseCount;

                    this.Text = "Menu item two selected %d" + recEvent.dwData.ToString();

                    //if (menuUseCount == 6)
                        //quit = 1;
                    break;

remember to add the events and group to your enums
 
I added SubMenus so I thought I'd post my C# code in case anyone else needed that capability.


simconnect.MapClientEventToSimEvent(EVENTS.MENU_TOP, "");
simconnect.MapClientEventToSimEvent(EVENTS.MENU_FORM1, "");
simconnect.MapClientEventToSimEvent(EVENTS.MENU_FORM2, "");
simconnect.MapClientEventToSimEvent(EVENTS.MENU_FORM3, "");
simconnect.MapClientEventToSimEvent(EVENTS.MENU_SEPARATOR, "");
simconnect.MapClientEventToSimEvent(EVENTS.MENU_QUIT, "");
simconnect.MenuAddItem("EZCamViews", EVENTS.MENU_TOP, 10000);
simconnect.MenuAddSubItem(EVENTS.MENU_TOP, "Form 1 Window", EVENTS.MENU_FORM1, 10001);
simconnect.MenuAddSubItem(EVENTS.MENU_TOP, "Form 2 Window", EVENTS.MENU_FORM2, 10002);
simconnect.MenuAddSubItem(EVENTS.MENU_TOP, "Form 3 Window", EVENTS.MENU_FORM3, 10003);
simconnect.MenuAddSubItem(EVENTS.MENU_TOP, "---------------------------", EVENTS.MENU_SEPARATOR, 10004);
simconnect.MenuAddSubItem(EVENTS.MENU_TOP, "Quit", EVENTS.MENU_QUIT, 10005);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_TOP, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_FORM1, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_FORM2, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_FORM3, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_SEPARATOR, false);
simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_MENU, EVENTS.MENU_QUIT, false);
simconnect.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP_MENU, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);

Since there is no formal menu separator, we have to make our own.
 
Back
Top