PBGetMenuString PowerScript function
Description
Gets the name of the item at a given position in a menu.
Syntax
1 |
<span>PBGetMenuString</span> ( <span>hmenu</span>, <span>nPos</span>, <span>caption</span>, <span>nMaxLength</span>) |
Argument |
Description |
---|---|
hmenu |
A long for the menu |
nPos |
An integer for the |
caption |
A string passed |
nMaxLength |
An integer that |
Return Values
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:
1 |
string ls_menu <br>long hmenu<br>long submenu<br>int ll_ret<br> |
1 |
hmenu = GetMenu(handle(w_main)) |
1 |
submenu = GetSubMenu(hmenu,0) |
1 |
ll_ret = <span>PBGetMenuString</span>(submenu,0,ls_menu,5) |
1 |
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:
1 |
function long GetMenu ( long hwnd) library "user32.dll" |
1 |
function long GetSubMenu ( long hparent,int pos) &      library "user32.dll" |