TOHCS
May 15th, 1999, 10:57 PM
I used the mscomm32.ocx in a SDI application and create an instance control dynamically in the CMainFreame. The code are as below:
//add in code to MainFrame.cpp
// add eventsink map to hook OnComm event
BEGIN_EVENTSINK_MAP(CMainFrame, CFrameWnd)
ON_EVENT(CMainFrame, ID_COMMCTRL, 1 /* OnComm */, OnComm1, VTS_NONE)
END_EVENTSINK_MAP()
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//addin code
if(!m_commctrl.Create(NULL,0,CRect(0,0,0,0),this,ID_COMMCTRL))
{
TRACE0("Failed to create OLE Communication Control\n");
return -1;
}
}
void CMainFrame::OnComm1()
{
}
//---------------
//addin code in mainframe.h
#define ID_COMMCTRL 2001 // Ctrl ID for comm control
protected: // control bar embedded members
CMSComm m_commctrl;
// Generated message map functions
protected:
afx_msg void OnComm1();
DECLARE_EVENTSINK_MAP()
My program work well on PC which have VC but given an error "Fail to create empty document" on PC whcih don't have VC installed. I'm sure that I already copied all needed dll and mscomm32.ocx files to system directory and also regster the mscomm32.ocx to the registry.
If a dialog bax application is develop then no error shown on the PC without VC++ . If any one know what wrong in my program, please help me in this. Thank you.
//add in code to MainFrame.cpp
// add eventsink map to hook OnComm event
BEGIN_EVENTSINK_MAP(CMainFrame, CFrameWnd)
ON_EVENT(CMainFrame, ID_COMMCTRL, 1 /* OnComm */, OnComm1, VTS_NONE)
END_EVENTSINK_MAP()
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//addin code
if(!m_commctrl.Create(NULL,0,CRect(0,0,0,0),this,ID_COMMCTRL))
{
TRACE0("Failed to create OLE Communication Control\n");
return -1;
}
}
void CMainFrame::OnComm1()
{
}
//---------------
//addin code in mainframe.h
#define ID_COMMCTRL 2001 // Ctrl ID for comm control
protected: // control bar embedded members
CMSComm m_commctrl;
// Generated message map functions
protected:
afx_msg void OnComm1();
DECLARE_EVENTSINK_MAP()
My program work well on PC which have VC but given an error "Fail to create empty document" on PC whcih don't have VC installed. I'm sure that I already copied all needed dll and mscomm32.ocx files to system directory and also regster the mscomm32.ocx to the registry.
If a dialog bax application is develop then no error shown on the PC without VC++ . If any one know what wrong in my program, please help me in this. Thank you.