Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Modules and Menu Bars

Featured Replies

I've got my module to display correctly on the FS menu bar, but I can't seem to intercept the clicks. I have a hook set for WH_CALLWNDPROC, and it works fine, but I'm not getting a WM_COMMAND message when I click on the menu bar. I thought WM_COMMAND was the message to look for when clicking the menu bar, but I guess not. If I open FSUIPC, I don't get a WM_COMMAND message until I click OK to close the dialog. I've also tried WM_MENUSELECT, but I'm having a hard time discerning the clicks on the sub menus from the main menus, along with highlites, etc. Any ideas? Thanks!

Matt Kaprocki

Boeing777_Banner_DevTeam.jpg

For fastest support, please submit a ticket at http://support.precisionmanuals.com

sounds interresting. However, WH_GETMESSAGE may get a lot of messages and ultimately, may impair the module in catching and treating all these messages could potentially affect performances in the sim. How does it work so far to this respect?

Here's my function for the WH_GETMESSAGE hook. Seems to work perfectly with no side effects. What way would you do it? WH_GETMESSAGE seems to be the only way I can catch a WM_COMMAND from a menu bar.LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam){ MSG *message; if (nCode >= 0) { message = (MSG *)lParam; if (message->message == WM_COMMAND) { if (LOWORD(message->wParam) == ID_FFS_ABOUT) { MessageBox(hwnd,"Flight Factory-Simulations!","FFS",MB_OK); } } } return CallNextHookEx(hhook_msgproc, nCode, wParam, lParam);}

Matt Kaprocki

Boeing777_Banner_DevTeam.jpg

For fastest support, please submit a ticket at http://support.precisionmanuals.com

Sounds great indeed. I miss-understood your use of GetMessage at first (and my Windows API knowledge as well :-) ) Since the hook is only called when the application calls for a GetMessage() or PeekMessage(), then you are right there is little overhead. I suspect that when you move your mouse a lot it sends a lot of messages in the queue, and for each the hook callback will have to test them though. But there are very few ways around anyhow!

I cant make my module to display correctly on the FS menu bar.Here is the code,Any and all help greatly appreciated. BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)HWND hWnd = FindWindow ("FS98MAIN", NULL);HMENU hMenu,hPopupMenu;switch(dwReason) { case DLL_PROCESS_ATTACH: hMenu=GetMenu(hWnd); hPopupMenu=CreatePopupMenu(); AppendMenu(hPopupMenu,MF_STRING,0x1016,"TEST"); AppendMenu(hMenu,MF_POPUP,(UINT)hPopupMenu,"test"); DrawMenuBar(hWnd); . . . . . break; case DLL_PROCESS_DETACH: . . . . DeleteMenu(hMenu,0x1016,MF_BYCOMMAND) break; }

It's pretty tricky to do. You need to set a hook using SetWindowsHookEx on WH_CALLWNDPROC. Then in CallWndProc, when you get a WM_INITMENU message, draw your menu. Here's how I create the menu for my module:hMenu = GetMenu(hwnd);SubMenu = GetSubMenu(hMenu, 0);MyMenu = CreatePopupMenu();AppendMenu(MyMenu, MF_STRING, ID_FFS_SETTINGS, "&Settings");AppendMenu(MyMenu, MF_SEPARATOR, 0, 0);AppendMenu(MyMenu, MF_STRING, ID_FFS_ABOUT, "&About");AppendMenu(SubMenu, MF_STRING | MF_POPUP, (UINT)MyMenu, "Flight Factory");SetMenu(hwnd, hMenu);

Matt Kaprocki

Boeing777_Banner_DevTeam.jpg

For fastest support, please submit a ticket at http://support.precisionmanuals.com

my code still have some problem. First,it cant get a WM_INITMENU message in CallWndProc. Second,it seem that the hook cant be released even using UnhookWindowsHookEx.LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam) { hWnd = FindWindow ("FS98MAIN", NULL); MSG *message; if(hWnd) { if (nCode >= 0) { message = (MSG *)lParam; if (message->message == WM_INITMENU) { hMenu = GetMenu(hWnd); SubMenu = GetSubMenu(hMenu, 0); MyMenu = CreatePopupMenu(); AppendMenu(MyMenu, MF_STRING, 12343, "&Test"); . . . } } return CallNextHookEx(hhookSysMsg, nCode, wParam,lParam);} BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved){ case DLL_PROCESS_ATTACH: hhookSysMsg = SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,hDLL,0); break; case DLL_PROCESS_DETACH: if(hhookSysMsg) UnhookWindowsHookEx(hhookSysMsg); break;}

Try hhookSysMsg = SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,0, GetCurrentThreadId());UnhookWindowsHookEx(hhook_winproc) works fine for me, what error do you get?Also, in CallWndProc(), you should be using a CWPSTRUCT, such as:CWPSTRUCT *message;if (nCode >= 0){ message = (CWPSTRUCT *)lParam; if (message->message == WM_INITMENU) { hMenu = GetMenu(hWnd); SubMenu = GetSubMenu(hMenu, 0); MyMenu = CreatePopupMenu(); AppendMenu(MyMenu, MF_STRING, 12343, "&Click Me!"); AppendMenu(SubMenu, MF_STRING | MF_POPUP, (UINT)MyMenu, "&Test"); SetMenu(hwnd, hMenu); DrawMenuBar(hwnd); }}

Matt Kaprocki

Boeing777_Banner_DevTeam.jpg

For fastest support, please submit a ticket at http://support.precisionmanuals.com

Thank you MKaprocki,now the hook can be released when exit FS.But the new menu only occurs when i clicks an item on the menu bar and disappear when menu bar not become active. WM_INITMENU occurs when the user clicks an item on the menu bar or presses a menu key,should i add some other code?Regards

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.