Example needed of using ActiveX control in NON MFC Win SDK Application
-
Hello, I am in need of a NON MFC sample project or code fragment that accesses a non-windowed ActiveX control. i.e., a control that doesn't have a GUI aspect to it like MSCOMM. After doing searches here and on MSDN, the only posts I've found suggest not to use the Win32 SDK, but to use MFC. In this instance, that is not an option. However, if there is an article that can be used to convince the customer otherwise and use MFC, that would be better. Right now they want to use the Win32 SDK with one of our ActiveX controls. Any help would be appreciated. Regards, Paul...
-
Hello, I am in need of a NON MFC sample project or code fragment that accesses a non-windowed ActiveX control. i.e., a control that doesn't have a GUI aspect to it like MSCOMM. After doing searches here and on MSDN, the only posts I've found suggest not to use the Win32 SDK, but to use MFC. In this instance, that is not an option. However, if there is an article that can be used to convince the customer otherwise and use MFC, that would be better. Right now they want to use the Win32 SDK with one of our ActiveX controls. Any help would be appreciated. Regards, Paul...
-
Thanks for the suggestion, but it doesn't explain much to me. Here is the call to the Create function of the control:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL)
What is used for the CWnd* parameter since the parent will get event messages? Do you have an example of how #import can be used for the call above? :confused: -
Thanks for the suggestion, but it doesn't explain much to me. Here is the call to the Create function of the control:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL)
What is used for the CWnd* parameter since the parent will get event messages? Do you have an example of how #import can be used for the call above? :confused:I am confused "..NON MFC sample ..." "...non-windowed ActiveX..." "...that doesn't have a GUI aspect...". In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement :). What I was proposing is following in stdafx.h (or main.h or whatever.h file you are using) #import "libid:12345" no_namespace //12345 being libid of your control in your code.cpp void somefunction() { //Note: IYourControlMainInterfacePtr and //YourControlsCoClass generated by #import IYourControlMainInterfacePtr spMain(__uuidof(YourControlsCoClass)); spMain->SomeMethodOnTheControl(); ..... }
-
I am confused "..NON MFC sample ..." "...non-windowed ActiveX..." "...that doesn't have a GUI aspect...". In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement :). What I was proposing is following in stdafx.h (or main.h or whatever.h file you are using) #import "libid:12345" no_namespace //12345 being libid of your control in your code.cpp void somefunction() { //Note: IYourControlMainInterfacePtr and //YourControlsCoClass generated by #import IYourControlMainInterfacePtr spMain(__uuidof(YourControlsCoClass)); spMain->SomeMethodOnTheControl(); ..... }
AlexO wrote: In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement Well, I see what you mean but actually I am not using MFC and I am not creating a CWnd based window. The line of code is the create function for the control. One of the parameters is a pointer to a CWnd. The application does have a Window but created using CreateWindow ...so this is where I am stuck. Can't use any temp CWnd object to attach to, but the window is needed to get messages from the control. The non-GUI aspect is that the control does not display a pie chart or something ...it is used to control an I/O device. I think I have a lot of reading to do, but not sure where to look to do this or even if I am going about it the right way. Thanks for the help. Regards, Paul...
-
AlexO wrote: In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement Well, I see what you mean but actually I am not using MFC and I am not creating a CWnd based window. The line of code is the create function for the control. One of the parameters is a pointer to a CWnd. The application does have a Window but created using CreateWindow ...so this is where I am stuck. Can't use any temp CWnd object to attach to, but the window is needed to get messages from the control. The non-GUI aspect is that the control does not display a pie chart or something ...it is used to control an I/O device. I think I have a lot of reading to do, but not sure where to look to do this or even if I am going about it the right way. Thanks for the help. Regards, Paul...
Thanks for the help. I really need to read up on this stuff! :~
-
AlexO wrote: In the sample above, you are creating window(1) and using MFC(2) for it. It kind of does not match the original requirement Well, I see what you mean but actually I am not using MFC and I am not creating a CWnd based window. The line of code is the create function for the control. One of the parameters is a pointer to a CWnd. The application does have a Window but created using CreateWindow ...so this is where I am stuck. Can't use any temp CWnd object to attach to, but the window is needed to get messages from the control. The non-GUI aspect is that the control does not display a pie chart or something ...it is used to control an I/O device. I think I have a lot of reading to do, but not sure where to look to do this or even if I am going about it the right way. Thanks for the help. Regards, Paul...
Control is the word, which probably confused us both. Here is the deal: even if your control has UI, you still (in most cases) can use it as a simple COM object. Since your control does not have UI, it simplifies the problem. In my example I showed how to create a COM object and call in method on it. My guess you do not need window, or at least do not need to attach your control to it.