Description
Gets the name of the item at a given position in a menu.
Syntax
PBGetMenuString ( hmenu, nPos, caption, nMaxLength)
Argument |
Description |
---|---|
hmenu |
A long for the menu handle |
nPos |
An integer for the position of the menu item, counting from 0 at the leftmost or topmost position |
caption |
A string passed by reference that captures the name (Text property) of the menu item |
nMaxLength |
An integer that sets the maximum length of the value passed in the caption argument |
Return value
Long. Returns 1if it succeeds and -1 if an error occurs. If any argument is null, PBGetMenuString returns null.
Usage
Use PBGetMenuString to get the name of a menu item. This function is useful for some automated testing programs that cannot get menu item names from the Text property for menus that use the contemporary style.
Examples
This statement gets the first menu item of the submenu of the w_main window using the GetMenu and GetSubMenu WIN32 API functions from the user.dll library:
string ls_menu long hmenu long submenu int ll_ret hmenu = GetMenu(handle(w_main)) submenu = GetSubMenu(hmenu,0) ll_ret = PBGetMenuString(submenu,0,ls_menu,5) messagebox ("Menu Test", "return value = & "+string(ll_ret)+ " menu caption is "+ls_menu)
This example assumes you have made the following Local External Functions declarations:
function long GetMenu ( long hwnd) library "user32.dll" function long GetSubMenu ( long hparent,int pos) & library "user32.dll"