Navision & the Windows API

Greetings, I am trying to access the Navision (Attain 3.01A) menu system through a VB6 application. I can access Navision’s windows and get handles to the main menu bar & menus. However, this is where I get stuck insofar that I have been unable to access Navision’s submenus. The attached VB code will iterate through an application’s menu recursively, so that each menu gets listed, then that menu’s submenus etc. And this works fine for most applications (I’ve tried Notepad & a few others), but for some reason Navision refuses to enumerate its submenus. Are there any programmers out there who know (or could guess) why this would occur? Or even better, know what to do about it? Thanking you. andre ps: Since I’m not allowed to upload text files (why not?) here’s a pseudo-code-ish snippet to give you an idea:


Sub ListNavisionMenuStructure()
    Dim hWnd As Long, hMenu As Long, hSubMenu As Long

    hWnd = GetApplicationHandle("Navision")
    hMenu = GetMenuHandle(hWnd)

    IterateMenus(hMenu)

End Sub

I’ll email the code (as txt file) on request.

You cannot access Navision’s menu bar. Not even from within Navision. Sorry, I don’t have a better answer. With best regards from Switzerland Marcus Fabian

Thanks Marcus, at least it’s an answer, if not the one I was after… Anyway, using API calls I do get a handle to the main menu bar as well as handles to all toplevel menus (File, Edit, View…). So you can access Navision’s menu bar, it’s just the submenus I can’t get to. Possibly due to the way in which (sub?)menus are implemented in Navision? Maybe due to my non-existing experience with the windows API. I’ll place my bets on the latter.

Yes, there’s a “Windows API trick” which allows you to hide the Navision Menu bar. The guys at Landsteinar have developped an OCX which is actually a component of their RBO add-on (Retail Back Office) which does actually hide the Navision Menu Bar. ###### tarek_demiati@ureach.com

Getting into the Windows menu’s is an adventure on its own and surely needs a good knowledge of the API routines. You may want to have a look at www.allapi.net for a download of their API Guide. I have found this an indispensable aid for developments in VB. Another help might be found in studying the ways that have been used to add a graphic to an menu-item, as there too you need to dive deep into the menu structure. See www.planetsourcecode.com for examples. John

Have you tried Spy++ from VisualStudio ? You can track all messages using this utility.

Unlike many other apps I have looked at, the Navision Attain executable lacks a menu resource. This leads me to assume that Navision’s menus are built on-the-fly, and may therefore not be available for you to customize. Could someone with a more thorough knowledge of the Windows API confirm if this could be possible at all? Kind regards, Jan Hoek Weha Automatisering BV Woerden - The Netherlands Edited by - jhoek on 2002 Jan 29 19:37:23

The menus are built on the fly. You can find the texts for the menu in the “fin.stx” file. However, as all the items in the menu have fixed IDs, it may be possible to access them through the API anyway. Lars Strøm Valsted ------------------------- Software development today is a race between the programmers trying to make better and more foolproof programs, and the universe trying to make bigger idiots. So far the universe is winning.

Hi, the client re-creates the menus dynamically whenever a window is closed, a new one is created or an other window is selected. Therefore the IDs are fix most of the time but only for the first level, so I’d recommend enumerating all menu levels every time you need access a menuitem. Torsten

quote:


Originally posted by lstroem: The menus are built on the fly. You can find the texts for the menu in the “fin.stx” file. However, as all the items in the menu have fixed IDs, it may be possible to access them through the API anyway. Lars Strøm Valsted ------------------------- Software development today is a race between the programmers trying to make better and more foolproof programs, and the universe trying to make bigger idiots. So far the universe is winning.