VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

API Menu Example v2

Danny Krotzer  (2 Submissions)   Windows API Call/Explanation   Visual Basic 5.0   Advanced   Wed 3rd February 2021

Like the first version, this shows how to access another application's menu and copy it in your own app using API...allowing you to actually call the menu functions in the other application from your menu.
The example creates a list of current windows (only windows with compatible menus). Then when selected, the menu is 'cloned' using API calls GetMenuItemInfo() and InsertMenuItem() allowing you to not only to copy the menuitem but the state of the menuitem.(Checked, Grayed, etc...)
And unlike the first version which only loaded 1 level of submenus, this will load all levels.
This example could also prove to be useful to anyone wanting to know more about creating dynamic menus and submenus in VB as well as how to handle messages from them when clicked (uses subclassing). Unlike many 'dynamic menu' examples, this does not require any 'dummy' menus or menu arrays to be created.
Demonstrates API Calls: IsWindow, SetWindowLong, EnumWindows, GetMenuItemCount, GetSubMenu, GetMenu, SetMenu, DestroyMenu, CreateMenu, CreatePopupMenu, DrawMenuBar, CallWindowProc, PostMessage, GetWindowTextLength, GetWindowText, IsMenu, GetMenuItemInfo, & InsertMenuItem.

Rate API Menu Example v2 (19(19 Vote))

Download API Menu Example v2

API Menu Example v2 Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters