创建7个子窗口对象实例
m_tabPages[0]=new CDlgMsgDeal;
m_tabPages[1]=new CDlgMsgSend;
m_tabPages[2]=new CDlgDataDeal;
m_tabPages[3]=new CDlgDataSend;
m_tabPages[4]=new CDlgDataMainten;
m_tabPages[5]=new CDlgControl;
m_tabPages[6]=new CDlgAllData;
////////////////////////////////////////////
运行到这个位置 电脑就死机 郁闷!
m_tabPages[0]->Create(IDD_MsgDeal, this);
m_tabPages[1]->Create(IDD_MsgSend, this);
m_tabPages[2]->Create(IDD_DataDeal, this);
m_tabPages[3]->Create(IDD_DataSend, this);
m_tabPages[4]->Create(IDD_DataMainten, this);
m_tabPages[5]->Create(IDD_Control, this);
m_tabPages[6]->Create(IDD_AllData, this);
//////////////////////////////////////////////////////
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
m_tabPages[2]->ShowWindow(SW_HIDE);
m_tabPages[3]->ShowWindow(SW_HIDE);
m_tabPages[4]->ShowWindow(SW_HIDE);
m_tabPages[5]->ShowWindow(SW_HIDE);
m_tabPages[6]->ShowWindow(SW_HIDE);
/////////////////////////////
setRectangle();
请高手帮我看看问题出在哪了!谢谢
如果还不行,就F11跟踪进去看看哪里出问题。
to: cnzdgs
很奇怪 最开始 只运行到这句才会弹出个对话框
m_tabPages[4]=new CDlgDataMainten;
并显示出个带有红色X的对话框,对话框窗体无提示文字,报错后死机.
后来不知道为什么到第一句运行就死机m_tabPages[0]->Create(IDD_MsgDeal, this);
.只能重起电脑.后跟进错误在m_tabPages[0]->Create(IDD_MsgDeal, this);
出错 pDlgInfo->m_ppOleDlgItems =
(DLGITEMTEMPLATE**)malloc(sizeof(DLGITEMTEMPLATE*) *
(DlgTemplateItemCount(pOrigTemplate) + 1));
这个位置.并弹出findSource对话框
///////////////////////////////////////////////////////////////////////////////////////////////
to:matrixnull
+ m_tabPages[0] 0x00cd47c0 {CDlgMsgDeal hWnd=0x00000000}
+ m_tabPages[1] 0x00cd5da0 {CDlgMsgSend hWnd=0x00000000}
+ m_tabPages[2] 0x00cd5e78 {CDlgDataDeal hWnd=0x00000000}
+ m_tabPages[3] 0x00cd5f50 {CDlgDataSend hWnd=0x00000000}
+ m_tabPages[4] 0x00cd6028 {CDlgDataMainten hWnd=0x00000000}
+ m_tabPages[5] 0x00cd6d48 {CDlgControl hWnd=0x00000000}
+ m_tabPages[6] 0x00cd76c0 {CDlgAllData hWnd=0x00000000}
应该是成功了吧
如把对话框改成child风格WINMAIN.CPP
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
这里会出错
m_tabPages[4]=new CDlgDataMainten;
并显示出个带有红色X的对话框,对话框窗体无提示文字,报错后死机.
后来不知道为什么到第一句运行就死机m_tabPages[0]->Create(IDD_MsgDeal, this);
.只能重起电脑.后跟进错误在m_tabPages[0]->Create(IDD_MsgDeal, this);
出错 pDlgInfo->m_ppOleDlgItems =
(DLGITEMTEMPLATE**)malloc(sizeof(DLGITEMTEMPLATE*) *
(DlgTemplateItemCount(pOrigTemplate) + 1));
这个位置.并弹出findSource对话框
如把对话框改成child风格WINMAIN.CPP
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
我是在OnInitDialog()里写的
{
BOOL bFound=FALSE;
int * hMutexOneInstantance=(int *)CreateMutex(NULL,TRUE,_T("PreventSecondInstance"));
if(GetLastError()==ERROR_ALREADY_EXISTS)
bFound=TRUE;
if(hMutexOneInstantance)
ReleaseMutex(hMutexOneInstantance);
if (bFound==TRUE)
{
::AfxMessageBox("此程序已经在运行!");
return false;
}
AfxEnableControlContainer();
AfxInitRichEdit();
AfxSocketInit(); ReadConfigFile();//读取配置文件
//初始化COM,创建ADO连接等操作
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection));
//尝试进行三次数据连接
try
{
m_pConnection->Open((LPSTR)(LPCTSTR)(m_csGlobeConnectString),"","",NULL);
}
catch(_com_error e)
{
Sleep(5000);
try
{
m_pConnection->Open((LPSTR)(LPCTSTR)(m_csGlobeConnectString),"","",NULL);
}
catch(_com_error e)
{
Sleep(5000);
try
{
m_pConnection->Open((LPSTR)(LPCTSTR)(m_csGlobeConnectString),"","",NULL);
}
catch(_com_error e)
{
AfxMessageBox("数据库连接失败,确认数据库配置信息是否正确!");
return FALSE;
}
}
} //创建主窗口
CmyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}全部都在这呢!
/////////////////////////////////////////////////////////////////////////////////////////////
注:
创建7个子窗口对象实例
这些都是在CmyDlg中的OnInitDialog内部写的
调用了下CDialog ::OnInitDialog();
然后就是
m_tabPages[0]=new CDlgMsgDeal;
m_tabPages[1]=new CDlgMsgSend;
m_tabPages[2]=new CDlgDataDeal;
m_tabPages[3]=new CDlgDataSend;
m_tabPages[4]=new CDlgDataMainten;
m_tabPages[5]=new CDlgControl;
m_tabPages[6]=new CDlgAllData;
////////////////////////////////////////////
m_tabPages[0]->Create(IDD_MsgDeal, this);
m_tabPages[1]->Create(IDD_MsgSend, this);
m_tabPages[2]->Create(IDD_DataDeal, this);
m_tabPages[3]->Create(IDD_DataSend, this);
m_tabPages[4]->Create(IDD_DataMainten, this);
m_tabPages[5]->Create(IDD_Control, this);
m_tabPages[6]->Create(IDD_AllData, this);
//////////////////////////////////////////////////////
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
m_tabPages[2]->ShowWindow(SW_HIDE);
m_tabPages[3]->ShowWindow(SW_HIDE);
m_tabPages[4]->ShowWindow(SW_HIDE);
m_tabPages[5]->ShowWindow(SW_HIDE);
m_tabPages[6]->ShowWindow(SW_HIDE);
/////////////////////////////
setRectangle();