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