Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Example needed of using ActiveX control in NON MFC Win SDK Application

Example needed of using ActiveX control in NON MFC Win SDK Application

Scheduled Pinned Locked Moved C / C++ / MFC
c++comsaleshelptutorial
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Belikian
    wrote on last edited by
    #1

    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...

    A 1 Reply Last reply
    0
    • P Paul Belikian

      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...

      A Offline
      A Offline
      AlexO
      wrote on last edited by
      #2

      use #import. It only includes and not other ATL/MFC.

      P 1 Reply Last reply
      0
      • A AlexO

        use #import. It only includes and not other ATL/MFC.

        P Offline
        P Offline
        Paul Belikian
        wrote on last edited by
        #3

        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:

        A 1 Reply Last reply
        0
        • P Paul Belikian

          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:

          A Offline
          A Offline
          AlexO
          wrote on last edited by
          #4

          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(); ..... }

          P 1 Reply Last reply
          0
          • A AlexO

            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(); ..... }

            P Offline
            P Offline
            Paul Belikian
            wrote on last edited by
            #5

            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...

            P A 2 Replies Last reply
            0
            • P Paul Belikian

              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...

              P Offline
              P Offline
              Paul Belikian
              wrote on last edited by
              #6

              Thanks for the help. I really need to read up on this stuff! :~

              1 Reply Last reply
              0
              • P Paul Belikian

                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...

                A Offline
                A Offline
                AlexO
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups