Jump to content
Sign in to follow this  
Guest eganm

Add Menu Items

Recommended Posts

Guest eganm

Hey All, I'm a learning programmer..in other words i'm trying to learn the C# language so i can write an addon for FSX. Anyways, I have a program that connects to simconnect and Fsx. But what I can't seem to do is have that program exist within Fsx and have a menu item within FSX for it. Ive spent hours trying to get the samples included with the SDK working and I must be missing something because I can't get them to work! I opened them with Microsoft C++ Express and they always contain errors. Anyway, any help with this would be very much appriciated. Thank you.

Share this post


Link to post
Share on other sites
Guest Itchycoo

Hi,Try this one: enum EVENTS { EVENT_MENU_ONE, EVENT_MENU_TWO, }; enum MENU_GROUP_ID { GROUP_MENU };Put these lines into initClientEvent():simconnect.MapClientEventToSimEvent(EVENTS.EVENT_MENU_ONE, "");simconnect.AddClientEventToNotificationGroup(MENU_GROUP_ID.GROUP_MENU, EVENTS.EVENT_MENU_ONE, false);simconnect.MapClientEventToSimEvent(EVENTS.EVENT_MENU_TWO, "");simconnect.AddClientEventToNotificationGroup(MENU_GROUP_ID.GROUP_MENU, EVENTS.EVENT_MENU_TWO, false);simconnect.MenuAddSubItem(EVENTS.EVENT_MENU_MAIN, "1st Menuitem", EVENTS.EVENT_MENU_ONE, 10001); //I think 10001 can be any number, I tried this onesimconnect.MenuAddSubItem(EVENTS.EVENT_MENU_MAIN, "2nd Menuitem", EVENTS.EVENT_MENU_TWO, 10002);simconnect.SetNotificationGroupPriority(MENU_GROUP_ID.GROUP_MENU, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);You can put your code into simconnect_OnRecvEvent://1st menu selectedcase (uint)EVENTS.EVENT_MENU_ONE://Put your code here for the 1st menubreak;//2nd menu selectedcase (uint)EVENTS.EVENT_MENU_TWO://Put your code here for the 2nd menubreak;Don't forget to remove menuitems before disconnect:simconnect.MenuDeleteSubItem(EVENTS.EVENT_MENU_MAIN, EVENTS.EVENT_MENU_ONE);simconnect.MenuDeleteSubItem(EVENTS.EVENT_MENU_MAIN, EVENTS.EVENT_MENU_TWO);This code works for me.Endre

Share this post


Link to post
Share on other sites
Guest eganm

Thanks for the reply, I had some problems with Simconnect and so couldn't try out what you suggested until today. To be honest I think my programming knowledge is too basic for this forum and I certainly don't wanna be one of those guys who just asks people to do it for them! So, if you can and don't mind helping me thanks and if not I understand. Anyways I couldn't get that code to work. No matter what I do it just won't compile for me with a huge amount of errors!! :( I think I have some basic things like where to put initclientevent() and things like that wrong. So a quick guide on this would be very helpful! Thanks.

Share this post


Link to post
Share on other sites

>Thanks for the reply, I had some problems with Simconnect and>so couldn't try out what you suggested until today. To be>honest I think my programming knowledge is too basic for this>forum and I certainly don't wanna be one of those guys who>just asks people to do it for them! So, if you can and don't>mind helping me thanks and if not I understand. >Anyways I couldn't get that code to work. No matter what I do>it just won't compile for me with a huge amount of errors!! :(>>I think I have some basic things like where to put>initclientevent() and things like that wrong. So a quick guide>on this would be very helpful! Thanks. I don't want to use this forum to pimp my blog a bunch, but the whole point of my simconnect tutorials is to start beginner programmers off towards writing simconnect programs in C#, so it might be a place to look.Also, Tim posted a great find in this online beginners C# book:http://www.programmersheaven.com/2/CSharpBook

Share this post


Link to post
Share on other sites
Guest DocMoriarty

And i noticed yesterday that in managed SimConnect (SP1) the data.uGroupID value upon receiving a menu event is not set to the correct group ID of the menu events. Instead i receive it with the UNKNOWN_GROUP like all other subscribed system events which cost me an hour since menu events were not recognized ...So as a good practice, don't assume that you'll receive any event with a correct group. Just use unique event IDs for your own stuff that don't interfere with system event id's to be on the safe side.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...