您如何访问未知控件的功能? [英] How do you access functionality of an unknown control?

查看:88
本文介绍了您如何访问未知控件的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由spy ++查看的我引用的控件的类名称为TBEGUIFileViewer.我可以通过简单地使用FromHandle(/*Handle provided by spy++*/)来引用该对象.....但是我不能使用CWnd的函数SetWindowText()等. "(不确定)),但似乎挂起了....这是代码:( http://msdn.microsoft.com/zh-CN/library/6fde5b3k(VS.80).aspx [

The class name of the control I''m referring as viewed by spy++ is TBEGUIFileViewer. I can reference to the object by simply using FromHandle(/*Handle provided by spy++*/).....but I can''t use CWnd''s function SetWindowText(), etc. I''ve found this code on msdn which is somewhat related (I''m not sure) but seems hanging....This is the code: (http://msdn.microsoft.com/en-us/library/6fde5b3k(VS.80).aspx[^])

<br />
   // IDC_MSACALCTRL1 is the ID of the Calendar control OCX embedded <br />
   // on this dialog<br />
   CWnd *pWndCal = GetDlgItem(IDC_MSACALCTRL1);<br />
<br />
   // Use the IUnknown of the control<br />
   LPUNKNOWN pUnk = pWndCal->GetControlUnknown();<br />
<br />
   // From there get the IDispatch interface of control<br />
   LPDISPATCH pDisp = NULL;<br />
   pUnk->QueryInterface(IID_IDispatch, (LPVOID*)&pDisp);<br />
<br />
   // use IDispatch method to invoke the control''s functionality<br />
<br />
   return TRUE;  // return TRUE unless you set the focus to a control<br />



之后我将如何处理LPDISPATCH/IDispatch?我该如何访问控件?请帮助.....谢谢



What am I going do with LPDISPATCH/IDispatch after? And how am I going access the control? Please help.....Thanks

推荐答案

如果它是一个ActiveX控件,那么它将仅具有IDispatch-如果它是一个ActiveX控件.普通控件,那么您将无法通过IDispatch对其进行控制.

您遇到的问题不是很容易解决.由于您不知道接口,因此您必须确定接口的作用.如果您感觉不够正常,则可以开始向控件发送消息并查看其功能.如果它具有任何自定义消息,命令或通知,那将不太可能有效.无限的可能性可能会有点沉重.

我个人将尝试查找原始开发人员,并要求他们描述控件的界面.如果不能,请使用相似的功能编写自己的内容.这比尝试对控件的界面进行反向工程要容易得多.

干杯,

It''s only going to have an IDispatch if it''s an ActiveX control - if it''s an ordinary control then you''re not going to be able to control it through IDispatch.

The problem you''ve got isn''t that easily solved. As you don''t know the interface you''re going to have to work out what is does. If you feel perverse enough you could start sending messages to the control and see what it does. That''s not likely to be that effective if it has any custom messages, commands or notifications. The sheer number of possibilities is likely to be a bit heavy.

Personally I''d try and find the original developer and ask them to describe the control''s interface. If you can''t then write your own with similar functionality. It''s likely to be easier than trying to reverse engineer the control''s interface.

Cheers,

Ash


这篇关于您如何访问未知控件的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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