如何从工具栏中获取所有按钮 [英] How to get all button from Toolbar

查看:145
本文介绍了如何从工具栏中获取所有按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何从工具栏中获取所有按钮并按下按钮?



我使用TB_BUTTONCOUNT来计算工具栏中有多少按钮。

返回给我的结果是正确的。

Hi,

How can I get all the button from toolbar and press the button?

I had using TB_BUTTONCOUNT to count got how many button inside my toolbar.
The result return to me is correct.

string sNotifyIconClass = "NotifyIconOverflowWindow";
hwndNotify = FindWindow(sNotifyIconClass, null);

hwndNotifyChild = FindWindowEx((IntPtr)hwndNotify, IntPtr.Zero, "ToolbarWindow32", null);

Int32 iCount = Convert.ToInt32(SendMessage((int)hwndNotifyChild,TB_BUTTONCOUNT,0,IntPtr.Zero));





但是,我无法使用TBBUTTONINFO检索工具栏中的每个按钮。



However, I can't retrieve each of the button inside the toolbar by using TBBUTTONINFO.

TBBUTTONINFO[] buttons = new TBBUTTONINFO[iCountItem];

for (int k = 0; k < iCountItem; k++)
{
    TBBUTTONINFO ti = new TBBUTTONINFO();
    ti.dwMask = TBIF_BYINDEX | TBIF_TEXT;
    ti.cbSize = (uint)Marshal.SizeOf(ti);

    SendMessage(new HandleRef(null, hwndChild), TB_GETBUTTONINFO, (IntPtr)k, ref ti);
    buttons[k] = ti;

    Int32 iCount = SendMessage((int)hwndChild, TB_PRESSBUTTON, 0, IntPtr.Zero);

}





请帮助。谢谢你提前。



Please help. Thanks in advanced.

推荐答案

http://stackoverflow.com/questions/17724168/win32-how-to-access-button-on-toolbar [ ^ ]

http://social.msdn.microsoft.com/Forums/vstudio/en-US/82cf3f2b-b661-47c5-854d-dcd42b0d45c4/how-to-click-toolbar-button-in-another-application-using-api? forum = csharpgeneral [ ^ ]


这篇关于如何从工具栏中获取所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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