Link to home
Start Free TrialLog in
Avatar of TommyN14
TommyN14

asked on

Error converting VS6 project to VS2008 Pro

Experts,

I'm converting a VS6 project to VS2008 Pro project using the VS08 Wizard.  After correcting all the compile errors, I was able to compile it.  This project has to do with watching TV on a PC.  It works fine in VS6.  After I converted to VS08, when I run the app, it said member not found and open up the TV window with no channel (rainy screen).  Below is the code snipets and where the program crashes.  TIA.

MyTest.h:
class CMyTestApp : public CWinApp
{
public:
      CMyTestApp ();
// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMyTestApp )
      public:
      virtual BOOL InitInstance();
      //}}AFX_VIRTUAL
                     ....
      DECLARE_MESSAGE_MAP()
};

MyTest.cpp:
...
#include "stdafx.h"
#include "MyTest.h"
#include "MyTestDlg.h"

BOOL CMyTestApp::InitInstance()
{
      if (!AfxSocketInit())
      {
            AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
            return FALSE;
      }
      AfxEnableControlContainer();
                      ...
      CMyTestDlg dlg;
      m_pMainWnd = &dlg;

      int nResponse = dlg.DoModal();
      if (nResponse == IDOK)
      {
      }
      else if (nResponse == IDCANCEL)
      {
      }
      return FALSE;
}

MyTestDlg.h:
//{{AFX_INCLUDES()
#include "_hcwwintvocx.h"
//}}AFX_INCLUDES
class CMyTestDlg : public CDialog
{
public:
      ...
      void SetChannel(int channel);
                     CMyTestDlg(CWnd* pParent = NULL);
                    // Dialog Data
      //{{AFX_DATA(CMyTestDlg )
      enum { IDD = IDD_MYTV };
      C_hcwWinTVocx      m_TV;
      //}}AFX_DATA
      
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMyTestDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);      // DDX/DDV support
      //}}AFX_VIRTUAL
                     ....
protected:
      HICON m_hIcon;
                     ....
private:
                     int m_chnl;
                     .....
};

MyTestDlg.cpp:
#include "stdafx.h"
#include "MyTestDlg.h"

CMyTestDlg::CMyTestDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CMyTestDlg::IDD, pParent),
        m_chnl( 0 ),
                       ....
{
      //{{AFX_DATA_INIT(CMonitorDlg)
      //}}AFX_DATA_INIT
      // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
      m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyTestDlg::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CMyTestDlg)
      DDX_Control(pDX, IDC_TV, m_TV);
      //}}AFX_DATA_MAP
}
...
BOOL CMyTestDlg::OnInitDialog()
{      
      CDialog::OnInitDialog();
      SetWindowText( "MY TV" );
      SetIcon(m_hIcon, TRUE);            // Set big icon

      m_TV.SetAnnunciatorEnabled( FALSE);      <<<< The program crashes right here   as soon as I start using m_TV object.
                     ....
}

Here is the _hcwwintvocx.h file (comes with the TVTuner)
class C_hcwWinTVocx : public CWnd
{
protected:
      DECLARE_DYNCREATE(C_hcwWinTVocx)
public:
      CLSID const& GetClsid()
      {
            static CLSID const clsid
                  = { 0x79ecb87e, 0x1510, 0x11d2, { 0xa9, 0x82, 0x0, 0xa0, 0xc9, 0x2a, 0x2d, 0xf } };
            return clsid;
      }
      virtual BOOL Create(LPCTSTR lpszClassName,
            LPCTSTR lpszWindowName, DWORD dwStyle,
            const RECT& rect,
            CWnd* pParentWnd, UINT nID,
            CCreateContext* pContext = NULL)
      { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }

    BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
            const RECT& rect, CWnd* pParentWnd, UINT nID,
            CFile* pPersist = NULL, BOOL bStorage = FALSE,
            BSTR bstrLicKey = NULL)
      { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
            pPersist, bStorage, bstrLicKey); }

// Operations
public:
                   void SetAnnunciatorEnabled(BOOL bNewValue);
                   .....
};

_hcwwintvocx.cpp file
#include "stdafx.h"
#include "_hcwwintvocx.h"
IMPLEMENT_DYNCREATE(C_hcwWinTVocx, CWnd)
....
void C_hcwWinTVocx::SetAnnunciatorEnabled(BOOL bNewValue)
{
      static BYTE parms[] =
            VTS_BOOL;
      InvokeHelper(0x6803ffce, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
             bNewValue);
}
....
Avatar of jkr
jkr
Flag of Germany image

>>when I run the app, it said member not found

It seems that the DISPID you are using with 'InvokeHelper()' is no longer valid. Have you tried regenerating the OLE wrappers?
Avatar of TommyN14
TommyN14

ASKER

jkr,

Thanks for your response.  I digged into the HCW OCX documentation and it said to select the hcwWinTVocx from Project->Add to Project->Components and Controls...(in VS6) and it will generate the _hcwwintvocx files.  I tried to do the samething in VS2008, but I couldn't find the Components & Controls options.  So I went to right click on the Toolbox->Choose Items...->COM Components and select that hcwWinTVocx, but it didn't regenerate the _hcwwintvocx files.  After this, I went to Resource View of the project and open the Diaglog IDD_MYTV and it crashed/shutdown VS2008.  Do you have any idea how I can regenerate these files or the OLE wrappers u mentioned?

Thanks!
Have you tried 'Project|Add Class...'?
jkr,

I tried Add Class as you suggested, this is what I did:  Project->Add Class->MFC Class From ActiveX Control.  In the Add Class From ActiveX Control Wizard window, I select the hcwWinTVocx (from registry), it doesn't show any Intefaces, so I can't select any interface to generate any class.  Am I doing something wrong here?

Thanks!
jkr, do you have anymore suggestions?

Anyone else has any ideas?

Please help!!!  Thanks!
Can you check the module in question with OLEView?
jkr,

How do I do that?

Thanks!
jdk,

so I ran the OLEView and under Interfaces, i saw about a doze of hcwWinTVocx, i select each of them and they have different info.  I don't know what to look for.  Attached is an example of one of them.

Please help.  Thanks!

test.gif
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't see any option from OLEView to generate IDL.  How do i do that?

Thanks!
Thank you!