Sign in to follow this  
rdart78

Text menu in vb.net or C#

Recommended Posts

Hello!

I'm trying to create a text menu in VB.net оr С# using the expression:

fsx_simconnect.Text(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.MENU, 0, Event_id.EVENT_MENU_1, "Title Menu" & vbNewLine & "Choose item:" & vbNewLine & "Item1" & vbNewLine & "Item2" & vbNewLine & "Item2")

but when I run it, I get an Exception 31 - SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS.

 

The problem in null chars in string "Title Menu" & vbNewLine & "Choose item:" & vbNewLine & "Item1" & vbNewLine & "Item2" & vbNewLine & "Item2".

 

The example in C++ "TextMenu" from SDK this line has the analog "Title Menu\0Choose item:\0Item1\0Item2\0Item2\0"? where null chars is "\0".

 

Expression:

fsx_simconnect.Text(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.PRINT_WHITE, 0, Event_id.EVENT_MENU_1, "Title Menu" & vbNewLine & "Choose item:" & vbNewLine & "Item1" & vbNewLine & "Item2" & vbNewLine & "Item2")

 

works without problems, and the string is divided into substrings correctly.

 

Tim “Beatle” Gregson in his blog https://fsandm.wordpress.com/2009/06/30/function-overloads/ mentions Managed SimConnect SDK, which, perhaps, could solve this problem. But I can't find any working links.

Can anyone help to solve this problem?

Best regards? Roman

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

You are calling two different machanisms, that is why one works and the other doesn't.

 

-> Type MENU needs string literals separated by null-characters'\0', these it will divide into the different lines of the menu (separate window like the ATC). Newline/carriage return/linefeed etc. do not work. The representation from the C# example is correct, and my guess is that you have to pass it to SimConnect exactly like that in VB too - in VB you may have to use something like CHR(0), it's been a while for me

 

-> Type PRINT_xy only needs a null character at the end (which your runtime will add for you) and displays the whole line as one string like the ATIS message

 

"Managed" are the SDK Libraries for C# and VB, the "non-managed" is for C++. If you are working with VB, you are already using the managed SDK libs. Beetle built an alternative SimConnect library with a few advantages over the default.

 

Bear in mind that these strings can only have a certain length, then they will be cut off.

 

If I were you, instead of VB I would switch to C# (more actually working examples, faster execution) or C++ (even more examples, highest performance)

Share this post


Link to post
Share on other sites

Thanks for the quick reply!

 

Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.MENU function in vb.net same this function in C#, but I can't find examples of implementation text menu in C# too.

 

Сan you write here the expression of this function correctly for version SIMCONNECT_TEXT_TYPE.MENU?

 

 

 

If I were you, instead of VB I would switch to C# (more actually working examples, faster execution) or C++ (even more examples, highest performance)

 

The transition from vb.net in C# I have no problem, but I can't implement text menu in C# too. 

 

In C++ I did it, but I have difficulties working with sounds in C++ and other opportunities, which in the .net languages is very easy to do.

Share this post


Link to post
Share on other sites

?

Just add the null-characters where you want the menu items to be split.

 

C#

simconnect.Text(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.MENU, 0, Event_id.EVENT_MENU_1, "Title Menu\0Choose item:\0Item1\0Item2\0Item2")

 

VB (assumed code, havent done this in a long time)

simconnect.Text(Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.MENU, 0, Event_id.EVENT_MENU_1, "Title Menu" & CHR(0) & "Choose item:" & CHR(0) & "Item1" & CHR(0) & "Item2" & CHR(0) & "Item2")


Thanks for the quick reply!

 

Microsoft.FlightSimulator.SimConnect.SIMCONNECT_TEXT_TYPE.MENU function in vb.net same this function in C#, but I can't find examples of implementation text menu in C# too.

 

Сan you write here the expression of this function correctly for version SIMCONNECT_TEXT_TYPE.MENU?

 

 

The transition from vb.net in C# I have no problem, but I can't implement text menu in C# too. 

 

In C++ I did it, but I have difficulties working with sounds in C++ and other opportunities, which in the .net languages is very easy to do.

 

Be careful with assuming the functions "are the same". This is not true for all of them, some work quite differently. And if you plan to go that way, be advised that P3D (V3) SimConnect is a little different as well, even if the doc looks the same at first glance - there are some subtle differences, almost hidden in the documentation, that have huge consequences. For example, in P3D V3 you have to explicitly cancel a data request on an object, even if that object has been deleted (!). This was not necessary with previous SimConnects, FSX knew that it makes no sense to send data for an object that does not exist any more...

Share this post


Link to post
Share on other sites

Thank you, friend! It works successfully! CHR(0) is something small that I could not understand. Now I get it.

 

 

 

Be careful with assuming the functions "are the same". This is not true for all of them, some work quite differently. And if you plan to go that way, be advised that P3D (V3) SimConnect is a little different as well, even if the doc looks the same at first glance - there are some subtle differences, almost hidden in the documentation, that have huge consequences.

 

You are right! I was a little wrong. I am programming vb.net. Understand the syntax of C#, don't know him well.

 

I will heed your advice. And hope we can in the future to ask you for help if need be.

 

Best regards, Roman.

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