VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



API Menu Example v2

by Danny Krotzer (2 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (18 Votes)

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

Download API Menu Example v2

Download API Menu Example v2 (6 KB)

API Menu Example v2 Comments

No comments have been posted about API Menu Example v2. Why not be the first to post a comment about API Menu Example v2.

Post your comment

Subject:
Message:
0/1000 characters