• 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.

Addon

Messages
2
Country
latvia
Hello!

I have question, how can I put my visual basic programmed client into FSX like addon? so I can see its menu in menu bar.
It is working and reading info from fsuipc and sending it to web. Basicly it is Virtual airline client.

Thanks!
 
I think you would need to create a module (.dll) that is then placed in the FSX Modules folder. It would need to conform to the standards and interfaces laid down for FS. I have not done it but of course others have - including FSUIPC. I suspect most are programmed in C++. Whether FS can handle a managed library created using VB.Net I do not know.
 
I am unsure if the FSX process would be the same as for FS2004 but I think it would be, the reason being that your program actually doesn't interact with FS at all. Your code only addresses offsets through FSUIPC. But don't blame me if I was wrong :D

There is an offset you have to write to, actually 3 offsets I believe.
Those have to be written every so often as the memory is cleared. I set my timer on 1000ms.

There are a limited number of available spots for menu items (55). You have to find the 1st empty one, reserve it, then write your menu caption and other parameters to it.
It's all in the SDK and info file that come with FSUIPC.

Going to check in one of my program...brb :)

And there you go, that's the 2004 method. You might get something out of it.
Actually if I remember correctly the FSUIPC help files and SDK are the same for both FS2004 & FSX

Setting the hotkey/reserving your spot in FS menu:
Code:
Public Sub CreateFS_MenuEntry()
'                               set up FS to display menu entry
'                               ===============================
Dim MenuIdx As Variant
Dim dwResult As Long
Dim tmpLng As Long
Dim tmpLng2 As Long

    If giMenuCnt = 0 Then Exit Sub
    
    gavHotkeyAddr_Menu(0) = GetFreeHotkeySpot(MenuIdx)       ' free key for menu
    gavHotkeyAddr_Menu(1) = MenuIdx
    gavHotkeyAddr_Menu(2) = "Checklist" & vbNullChar

    ' write the value to FS in this order: hotkey spot, menu index, menu text
    tmpLng = &HFFFF
    tmpLng2 = &H0
    
    [COLOR="Red"][B]' That's where you write to the 3 offsets[/B][/COLOR]
    Write_UIPC CLng(gavHotkeyAddr_Menu(0)), 2, tmpLng
    Write_UIPC CLng(gavHotkeyAddr_Menu(0)) + 2, 2, tmpLng2
    Write_UIPC &H2FE0, 1, CLng(gavHotkeyAddr_Menu(1))
    WriteS_UIPC &H2FE1, gavHotkeyAddr_Menu(2), False
    
    frmMain.TimerMenu.Enabled = True
    frmMain.TimerFSmenuHotkey.Enabled = True
End Sub

Supporting functions:
Code:
Public Function GetFreeHotkeySpot(Optional Idx As Variant) As Long
Dim n As Integer

    For n = 1 To 55
        ' find an empty hotkey spot
        Read_UIPC CLng(&H3210) + (4 * n), 1
        If gvRetVal = 0 Then
            GetFreeHotkeySpot = &H3210 + (4 * n)
            If Not IsMissing(Idx) Then Idx = n
            Exit Function
        End If
    Next n
End Function

Code:
Public Function Write_UIPC(lOffset As Long, lLen As Long, lValue As Long) As Boolean
Dim dwResult As Long

    ' Call to UIPC
    If FSUIPC_Write(lOffset, lLen, VarPtr(lValue), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            Write_UIPC = True
        End If
    End If
End Function

Code:
'--- Write request ------------------------------------------------------
Function FSUIPC_Write(dwOffset As Long, dwSize As Long, pSrce As Long, 
   This function is part of the module that is in the VB SDK
End Function



Oh geez, that was just to show your menu item in FS. I forgot how to actually link the item to your code. I do remember it's with hotkeys though.
Found it:

This timer I set to 500ms.

Retrieving the menu click:
Code:
Private Sub TimerFSmenuHotkey_Timer()
Dim dwResult As Long
Dim iBingo As Integer
Dim tmpStr As String
Dim tmpSng As Single
Dim pos As Integer

    ' Returns 1 if menu clicked
    If FSUIPC_Read(CLng(gavHotkeyAddr_Menu(0)) + 3, 1, VarPtr(iBingo), dwResult) Then    ' read pointer to hotkey
        If FSUIPC_Process(dwResult) And iBingo = 1 Then                 ' Bingo we got keypress
            frmKneeboard.Show
            
            Write_UIPC CLng(gavHotkeyAddr_Menu(0)) + 3, 1, 0            ' reset the trigger
        End If
    End If
    
    DoEvents
End Sub

The value of gavHotkeyAddr_Menu(0) was stored in the sub CreateFS_MenuEntry when we call the function GetFreeHotkeySpot. It is the beginning of your 3 reserved offsets.

In the line of code: If FSUIPC_Process(dwResult) And iBingo = 1 Then
if the menu was clicked the test will return true and you can put any code there. Mine was opening a checklist form.

I hope that helps and works for you. I am at your disposition if more info is needed.

P.S. You can use the excellent program that comes with FSUIPC (FSInterrogate2std) to figure out and read (or even write) all offsets.

Must read: FSUIPC for Programmers.pdf, search for "HOT KEYs for Applications".
 
Last edited:
Back
Top