|
@@ -634,15 +634,8 @@ void CMainFrame::OnCameraCombobox()
|
|
|
if ( pView->m_pCamera )
|
|
|
delete pView->m_pCamera;
|
|
|
pView->m_pCamera = NULL;
|
|
|
- //pView->GetDocument()->OnCloseDocument();
|
|
|
-
|
|
|
- //pView->SendMessage(WM_CLOSE, 0, 0);
|
|
|
- //pView->CloseWindow();
|
|
|
- //m_pChildFrame->MDIDestroy();
|
|
|
- m_pChildFrame->CloseWindow();
|
|
|
- //m_pChildFrame->DestroyWindow();
|
|
|
- //m_pChildFrame->SendMessage(WM_CLOSE, 0, 0);
|
|
|
- //delete m_pChildFrame;
|
|
|
+ pView->DestroyWindow(); //pView->SendMessage(WM_CLOSE, 0, 0);
|
|
|
+ m_pChildFrame->DestroyWindow(); //m_pChildFrame->SendMessage(WM_CLOSE, 0, 0);
|
|
|
m_pChildFrame = NULL;
|
|
|
}
|
|
|
|
|
@@ -653,7 +646,9 @@ void CMainFrame::OnCameraCombobox()
|
|
|
m_pChildFrame = new CChildFrame();
|
|
|
context.m_pLastView = NULL;
|
|
|
context.m_pCurrentFrame = this;
|
|
|
- context.m_pCurrentDoc = m_pDoc;
|
|
|
+ // 不要使用m_pDoc,这个是会在第一次随m_pChildFrame->DestroyWindow或m_pChildFrame->SendMessage(WM_CLOSE, 0, 0);销毁
|
|
|
+ // 再次使用时m_pDoc是野指针,导致LoadFrame出错;
|
|
|
+ context.m_pCurrentDoc = NULL;//m_pDocTemplate->CreateNewDocument();
|
|
|
context.m_pNewViewClass = RUNTIME_CLASS(CFieldTestToolView);
|
|
|
context.m_pNewDocTemplate = m_pDocTemplate;
|
|
|
|
|
@@ -1045,7 +1040,7 @@ BOOL CMainFrame::OnDeviceChange(UINT nEventType, DWORD_PTR dwData)
|
|
|
{
|
|
|
OutputDebugString(_T("设备有变化===============\n"));
|
|
|
// 新增时,需要等待系统刷新后才能遍历设备(有时仍不灵,添加刷新按钮处理);
|
|
|
- if ( nEventType == DBT_DEVICEARRIVAL)
|
|
|
+ if ( nEventType == DBT_DEVICEARRIVAL )
|
|
|
Sleep(1000);
|
|
|
|
|
|
EnumDevices(vtDevices);
|
|
@@ -1069,15 +1064,13 @@ BOOL CMainFrame::OnDeviceChange(UINT nEventType, DWORD_PTR dwData)
|
|
|
if ( pView->m_pCamera )
|
|
|
delete pView->m_pCamera;
|
|
|
pView->m_pCamera = NULL;
|
|
|
- pView->CloseWindow();
|
|
|
pView->DestroyWindow();
|
|
|
|
|
|
- m_pChildFrame->CloseWindow();
|
|
|
+ m_pChildFrame->DestroyWindow();
|
|
|
m_pChildFrame = NULL;
|
|
|
|
|
|
// 设备移除后,设置空;
|
|
|
pCameraCombo->DeleteItem(nCurSel);
|
|
|
- //pCameraCombo->SelectItem(-1);
|
|
|
}
|
|
|
}
|
|
|
|