如何使用Api获取MenuItem检查状态 [英] how to use Api get the MenuItem checked state

查看:100
本文介绍了如何使用Api获取MenuItem检查状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我得到了其他软件的菜单句柄,但我想知道Menu的MenuItem是处于检查状态还是未检查状态,如何使用windows api获取其他软件的MenuItem状态。



[DllImport(user32.dll)]

public static extern int GetMenuState(int hMenu,int wID,int wFlags);



private int MF_BYPOSITION = 0x400;



int it = GetMenuState(menuHandle,2,MF_BYPOSITION);



我确定menuHandle值是正确的,但它返回值等于-1,我找不到原因。
有人可以帮我吗?

If I got the other software's Menu handle,but i want to know Menu's MenuItem whether is checked state or unchecked state,how to use windows api to get the other software's MenuItem state.

[DllImport("user32.dll")]
public static extern int GetMenuState(int hMenu, int wID, int wFlags);

private int MF_BYPOSITION = 0x400;

int it = GetMenuState(menuHandle, 2, MF_BYPOSITION );

I'm sure the menuHandle value is correct,but return value it aways equals -1,i can't find out the reason.
can anybody help me?

推荐答案

我希望这不是明显的,但是通过指定MF_BYPOSITION,这意味着第二个参数是项目索引,它是一个基于零的索引。如果您有2个项目,则编号为0和1.



如果使用MF_BYCOMMAND,则第二个参数是感兴趣项目的命令ID。如果我正在编码,我会使用MF_BYCOMMAND。
I hope this isn't stating the obvious but by specifying MF_BYPOSITION, this means that the second parameter is the item index, which is a zero based index. If you have 2 items, they are numbered 0 and 1.

If you use MF_BYCOMMAND, then the second parameter is the command ID for the item of interest. If I was coding this, I would use MF_BYCOMMAND.


这篇关于如何使用Api获取MenuItem检查状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆