locked
Using an Interop-Control from Visual C++ 6.0

    คำถาม

  • What i want:

    Recently I want to use my Interop-Control not only from Visual Basic 6.0 but also from Visual C++ 6.0.

     

    What i do:

    - creating an simple interop-control with a button on it.

    - implementing the click event of the button (doesn't matter what it does and the reason for that button will clear up later)

    - compiling it to generate the interop-dll

    - opening my VC++6.0-IDE and create a new mfc-project

    - rightclick on the (created) dialog and choose "Insert ActiveX Control"

    - selecting the interop-dll 

    - (the control appears on the dialog)

    - (now i want to add the control to the dialog as a member to call the control's methods)

    - rightclick on the dialog and choose "MFC Class Wizard"

    - changing to the tab "Member Variable", choose the control-id of the interop-control and click on "Add Variable"

     

    The problem:

    VC++ wants to create a member with the type 'object'. But i want to have the controls-type, so i can see/call the methodes of it!?!

     

    Maybe it works, when I wrapper that interop-control with a VB6-control!?! Let try it:

    - creating a ActiveX-project in VB6 with a usercontrol

    - adding the interop-control the the vb6-project and insert it on the usercontrol

    - implement wrapper-functions for the functions of the interop-control, so the VB6-control can forward the calls

    - compiling the vb6-project to generate the ocx

    - opening my VC++6.0-IDE and create a new mfc-project

    - rightclick on the dialog and choose "Insert ActiveX Control"

    - selecting the VB6-ocx 

    - (the control appears on the dialog)

    - rightclick on the dialog and choose "MFC Class Wizard"

    - changing to the tab "Member Variable", choose the control-id of the VB6-control and click on "Add Variable"

    - YEHAAA... the member is typed and I can see/call all functions, which are forwarded through the VB6-control

     

    The problem:

    - run the project

    - simply click on the button of the interop-control

    - The application freezes and in the taskmanager the status of the test-application is set to "not responding"

     

    What's strange:

    The click-event itself is somehow the problem. 

    If I replace the click-event in the interop-control with an mousemove-event the application runs fine.

     

    So, again: What i want:

    I just want to use my Interop-Control from VC++6.0.

    How can I do this, without this problems?

     

     

    Thanks in advance,

    Jobacca

    22 พฤศจิกายน 2554 10:45

ตอบทั้งหมด

  • Hi Jobacca,

    Welcome to the MSDN Forum.

    This is a quick note to let you know that I am performing research on this issue and will get back to you as soon as possible.

    I apprieciate your patience.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    24 พฤศจิกายน 2554 18:47
  • Hi Jabacca,

    Can you tell me the steps you created the interop control?


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Regards,
    Jacky Wu
    Microsoft Online Community Support
    29 พฤศจิกายน 2554 3:12
  • First of all: thanks :)

     

    Here is how i created the interop-control:

    - creating a new project (VB6 Interop UserControl)

    - drag a button on the Usercontrol and impelementing the Click-Event

    - implementing a testfunction "Public Function HelloWorld() as Boolean"

    - compiling with .net 4

    - thats all. it's a virtual machine with winxp sp3

     

    here you can download the project-files

    I hope it will help you!

     

    Big thank you,

    Jobacca

    29 พฤศจิกายน 2554 16:56
  • Hi Jobacca,

    I have tried your first solution(use mfc dialog application to host the interop directly) in vs2010, seems that the solution works well(the button's click event can fire successfully, pop up a message and without hang))

    My steps is:

    1. Install vs2010,
    2. Install Microsoft InteropForms Toolkit 2.1
    3. Create the vb6 interop user control as you said
    4. Host the generated interop in mfc dialog application by "Insert ActiveX control"
    5. Add variable for the interop control as you said, note that a mfc wrapper class for the interop is generated automatically then.

     

    I guess the reason you fail is you are using vc6 rather than vs2010. Unfortunately, I have no vc6 at hand to check. Maybe vs2010 is a way for you to continue your work.

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Regards,
    Jacky Wu
    Microsoft Online Community Support
    30 พฤศจิกายน 2554 9:15
  • Sorry! I stucked in other things the last time.

    The existing application which was developed over many years should became to an hybrid-application. More and more parts should be managed. But the executable still has to be unmanaged. Thats, why we want to use .net-controls via interop. 

    25 มกราคม 2555 14:16
  • You can still build unmanaged/native C++ apps from VS 2010. Have you tried upgrading your VC6 project to VS 2010?
    25 มกราคม 2555 18:36