Tech Support > Microsoft Windows > Development Resources > How to read menu settings
How to read menu settings
Posted by Ritchie on July 17th, 2003


Hi All,
How would I go about having my app read the menu settings of another app?
For instance, take Calc.exe, how could my app read the 'View' menu to see
if Standard or Scientific was selected, or whether Degrees, Radians or
Grads was selected etc?

In this particular case, I could probably enumerate the windows to
determine the current modes, but I'm specifically interested in how to
read the menu settings.

--
Rich


Posted by Jugoslav Dujic on July 17th, 2003


Ritchie wrote:
<snip>
| BTW, I couldn't get it to work using MF_BYPOSITION despite trying various
| indexes. How are those menu's are numbered???

They're numbered normally, from 0 to nItems. However, the catch is that
all the menu we see is not a single HMENU -- every submenu is a menu
for itself, and you can get its handle using GetSubMenu(hMenu, Index).
MF_BYCOMMAND (usually) operates on entire menu tree, so you can retrieve
sub-(sub-)items by just supplying the root menu handle.
For MF_BYPOSITION to work, you have to traverse the tree yourself to
access submenuts.

--
Jugoslav
___________
www.geocities.com/jdujic


Posted by Ritchie on July 17th, 2003


"Jugoslav Dujic" <jdujicREMOVE@uns.ns.ac.yu> wrote in message news:bf6c6d$bdb8l$1@ID-106075.news.uni-berlin.de...
Sooooo, using Calc.exe as an example, would the indexes be:-

0 = 'Copy Ctrl+C'
1 = 'Paste Ctrl+V'
2 = 'Standard'
3 = 'Scientific'
etc...

And would the index for 'Help Topics' change when the calculators mode
was changed from standard to scientific (and vice-versa)? Think I'll
stick with MF_BYCOMMAND. I use SPY++ to obtain the menu ID by monitoring
WM_COMMAND messages whilst manually selecting the menu item of interest.
May be there is a way for SPY++ to also obtain the menu index?

Thanks
--
Ritchie



Posted by Ritchie on July 18th, 2003


"John Carson" <donaldquixote@datafast.net.au> wrote in message news:3f175e18@usenet.per.paradox.net.au...
Thanks Guys, I understand now. Here's the equivalent code for what I posted
earlier this time using MF_BYPOSITION:-

void main(void)
{
int res;
HWND hwnd = FindWindow("SciCalc", "Calculator");

if(hwnd) {
res = GetMenuState(GetSubMenu(GetMenu(hwnd), 1), 0, MF_BYPOSITION);
printf("%s\n", (MF_CHECKED & res) ? "Standard" : "Scientific");
}
}

Regards,
--
Ritchie




Similar Posts