[C#,工具栏]获取ToolBarButton的问题 [英] [C#, Toolbar] Problem with getting ToolBarButton
问题描述
你好,我今天在这里看到你一个问题,这是我很多天都无法解决的问题...
我创建了一个集成在Windows任务栏中的工具栏(例如Windows Media Player).
您可以在此处找到示例:http://goo.gl/PThTD
问题在于工具栏应该能够与另一个应用程序通信.然后我意识到我需要使用"Windows Messaging".
我找到了一个通常可以检索条形按钮(TB_GETBUTTON
)的按钮.
现在我无法使用它.
我在互联网上找到了一个教程,其中提供了一个使用示例:
Hello, I am here today to see you about a problem that I can''t solve since many days...
I created a toolbar integrated into the Windows taskbar (like windows media player).
You will find an example here: http://goo.gl/PThTD
The problem is that the toolbar should be able to communicate with another application. I then realized that I needed to use the "Windows Messaging".
I found one that normally allows me to retrieve the bar buttons (TB_GETBUTTON
).
Now I can not use it.
I found a tutorial on the internet, which gives an example of use:
TBBUTTON tbButton;
TBBUTTON* ipRemoteBuffer = & tbButton; // unsafe
for ( int i = 0 ; i < count ; i++ )
{
User32.SendMessage(
hToolbar,
TB_GETBUTTON,
( IntPtr ) i,
ipRemoteBuffer );
}
现在使用中,您会得到一个错误,因为编译器不再允许使用此实现...
我找不到在此函数的最后一个参数中放入什么来检索按钮.
Now in use, you get an error because the compiler no longer allows the use of this implementation ...
I can not find what to put in the last parameter of this function to retrieve the button.
User32.SendMessage (
toolbar,
TB_GETBUTTON,
IndexButton
(IntPtr) variable);
我的按钮位于工具栏中的"ToolBarButton"中,然后键入"ToolBar".
如果您有任何想法或建议或其他任何东西,我会很感兴趣.
预先谢谢你
-
Mat29100
My buttons are of the "ToolBarButton" my bar and type "ToolBar".
If you have any ideas or advice or anything, I''m interested.
Thank you in advance
-
Mat29100
推荐答案
最后一个参数应该是指向TBBUTTON结构的指针. 您发送的消息将通过该结构检索工具栏按钮的详细信息.
例如
The last parameter should be a pointer to a TBBUTTON structure.
And the message you send retrieves the toolbar button''s details through that structure.
Eg
TBBUTTON tbBtn = new TBBUTTON();
SendMessage(hToolbar, TB_GETBUTTON, i,
tbBtn);
TBBUTTON结构包含一些信息,例如它的状态/样式等.
请检查msdn,以获取有关结构&的更多详细信息.用法.
您对该函数的互操作定义为
The TBBUTTON structure holds some info like it''s state/style etc.
Check the msdn for more details on the structure & usage.
Your interop definition for the function would be
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, out TBBUTTON tbBtn);
(您还必须定义TBBUTTON结构)
(you''ll have to define the TBBUTTON structure as well)
好,谢谢.我会尝试您的解决方案.
但是我还有另一个问题.类型"TBBUTTON"和"ToolBarButton"之间有什么区别?
Ok, thanks you. I''ll try with your solution.
But i have an other question. What is the diference between the types ''TBBUTTON'' and ''ToolBarButton'' ?
这篇关于[C#,工具栏]获取ToolBarButton的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!