WindowsForms.CONTROLS如何使用ActiveX,(Auto)Wrap函数,IDispatch指针访问CONTROLS集合 [英] WindowsForms.CONTROLS how to access CONTROLS collection by using ActiveX, (Auto)Wrap function, IDispatch pointers

查看:98
本文介绍了WindowsForms.CONTROLS如何使用ActiveX,(Auto)Wrap函数,IDispatch指针访问CONTROLS集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:


我正在使用Visual C ++ Express Edition,而我正在项目中使用Windows Forms;事实上,我的项目还使用IDispatch指针打开Excel应用程序 - 指向我的Excell应用程序 - 和(自动)换行功能,它还
从特定的Excell表中写入/读取单元格使用类似的IDispatch指针(现在它们指向"工作簿"和"工作表"集合,依此类推......直到达到指定的单元格)


如果你理解所有上述内容或对我正在谈论的内容有所了解,请继续阅读...


问题是我想通过使用我的Windows窗体访问CONTROLS集合C ++。也许我需要一些IDispatch指针 - 首先指向我的Window窗体,然后是另一个IDispatch指针指向CONTROLS集合...如果
so,那么我想从CONTROLS访问一些属性和方法( .Name,.Item,.Count等)


我有一个用Visual Basic编写的代码,并且使用了类似于下面示例的指令,并在Visual Basic中正常工作。 (现在我正在尝试迁移到Visual C ++,该代码最初用VBasic编写)


可视化的基本代码,用于执行"控制"操作。属性和方法:


昏暗myControl作为对象


                    设置myControl = Controls.Item(指数)

                &NBSP ;   myString  =  myControl.Name                                                                  


For  J =  1 To(Controls.Count - 1)  ...  



>>>换句话说,您是否有关于如何在可视化C ++中以可视化方式编写代码的想法? 或者,如果你知道IDispatch指针,那么如何指向WINDOWS表格"CONTROLS"。采集? (一旦有
这样的指针指向Controls集合,我就更容易访问那些[控件]属性,例如.Count 和.Name   和Methods - 例如.Item



我将非常感谢您的建议和代码 示例。再次,请回答那些了解IDispatch指针,ActiveX对象和自动化的人, (或与关于等效代码&NBSP非常良好的知识;从Visual Basic到Visual C ++) 


感谢您的问候,                                

解决方案


我认为我们应该考虑如何与VC ++项目进行沟通Vb项目。如果VC ++无法直接访问excel,我们可以使用VB作为包装来传递一些导入值。

 

有三种方法,C ++调用.net程序集。请查看

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/0a0342e4-caec-42d0-bfe5-e0930883f141


另外,你可以尝试在两个应用程序之间使用IPC

http:// stackoverflow.com/questions/2012210/ipc-between-net-and-c-applications


最好的问候,

Jesse


Hi:

I'm using Visual C++ Express Edition and I'm using Windows Forms in my project; as a fact, my project also opens an Excel application by using an IDispatch pointer -pointing to my Excell application- and an (Auto)Wrap function, it also writes/reads cells from a specific Excell sheet by using similar IDispatch pointers (now they're pointing to the "Workbooks" and "Worksheets" collection, and so on...till the specified cells are reached)

If you understand all of the above or have an idea about what I'm talking about, please continue reading...

The PROBLEM is I would like to access the CONTROLS collection in my Windows Form by using C++ . Perhaps I would require some IDispatch pointer to -firstly- point to my Window Form and later another IDispatch pointer to point to the CONTROLS collection...if so, then I would like to access some Properties and Methods from CONTROLS (.Name, .Item, .Count, etc)

I have a previous code written in Visual Basic and instructions similar to the examples below were used and worked OK in Visual Basic. (Now I'm trying to migrate to Visual C++ that code originally written in VBasic)

VISUAL BASIC CODE TO ACCES THE "CONTROLS" PROPERTIES AND METHODS:

Dim myControl As Object

                    Set myControl = Controls.Item(index)
                    myString = myControl.Name                                                                 

For J = 1 To (Controls.Count - 1) ...  

>>> IN OTHER WORDS, DO YOU HAVE AN IDEA ABOUT HOW TO WRITE THE CODE IN VISUAL BASIC IN VISUAL C++?  or, If you're aware about the IDispatch pointers, HOW TO POINT TO THE WINDOWS FORM "CONTROLS" COLLECTION? (once having such pointer to the Controls collection, it would be easier to me to access those [Controls] properties such as .Count and .Name   and Methods -such as .Item

I would appreciate your suggestions and code example. Again, please answer only those aware of the IDispatch pointers, ActiveX objects and Automation, (or with very good knowledge about the equivalent code from Visual Basic to Visual C++) 

Thank you. Regards,                               

解决方案

Hi,

I think we should consider how to communicate VC++ project with Vb project. If VC++ cannot access the excel directly, we can use VB as a wrapper to pass some import values.
 
There are three way to do this, C++ call .net assembly. Please take a look of
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/0a0342e4-caec-42d0-bfe5-e0930883f141

Also, you can try to use IPC between two application
http://stackoverflow.com/questions/2012210/ipc-between-net-and-c-applications

Best regards,
Jesse


这篇关于WindowsForms.CONTROLS如何使用ActiveX,(Auto)Wrap函数,IDispatch指针访问CONTROLS集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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