2 Replies - 7042 Views - Last Post: 14 September 2007 - 08:07 AM Rate Topic: -----

#1 ifitzgerald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-September 07

Adding MSCOMM contol to Visual C++ Application

Posted 14 September 2007 - 06:33 AM

Hi,

I am modifying a rather large and complex MFC application (written by someone else) written in Visual C++ 6.0 with service pack 6. I need to add serial communication functionality to the program, and since I am very familiar with the Microsoft Comm Control from Visual Basic I decided that I would use that in this application.

To make things easier on myself, I decided to make several test applications using the MS Comm control in VC++ prior to modifying the large program. My test applications have been successful in communicating over the serial port.

However, as soon as I attempt to add the MS Comm Control to the form of the larger, more complex application it fails to run. It compiles successfully with no errors or warnings, but when I run it it exits immediately. I've tried stepping through it, but the only way I can manage to catch anything is if I set a breakpoint on the constructor of the main form. It doesn't even get far enough to call OnInitDialog!

As soon as I remove the MS Comm Control from the form and comment out any references to it in code the program once again runs. I'm really at wit's end here. I would greatly appreciate any help.

The reason I haven't included any code in this post is because I'm not sure what would be helpful - as far as the MSComm control goes, the only code that references it in the complex application was automatically generated, such as adding a member variable to the form's class, including the CMSComm.h file, etc. If you'd like to see anything in particular let me know.

Thanks,
Ian

Is This A Good Question/Topic? 0
  • +

Replies To: Adding MSCOMM contol to Visual C++ Application

#2 ifitzgerald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-September 07

Re: Adding MSCOMM contol to Visual C++ Application

Posted 14 September 2007 - 06:57 AM

I just had an epiphany!

Whenever I created a VC++ MFC application, I always made sure that "ActiveX Controls" support was checked. I just created an application without the ActiveX support included to see what would happen if I tried to include the MSComm control anyway. Sure enough, it compiles with no errors or warnings, but it exits immediately when I try to run it!

So now I have the question, what does checking the include "ActiveX Controls" support actually do? Does it just add directives or includes that I can add after the fact? How can I include support for ActiveX controls in an application that previously did not include that support?

Thanks,
Ian
Was This Post Helpful? 0
  • +
  • -

#3 ifitzgerald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-September 07

Re: Adding MSCOMM contol to Visual C++ Application

Posted 14 September 2007 - 08:07 AM

I found the solution to my problem:

Checking the "ActiveX Controls" support checkbox does a few things:
1) Adds #include <afxdisp.h> to StdAfx.h
2) Adds a call to AfxEnableControlContainer(); in the application's InitInstance function.

Once I added those two things to my larger, more complex application it ran fine.

Ian
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1