Explorar el Código

1、仍然有"OLE 初始化失败。请确保OLE库是正确的版本。"

scbc.sat2 hace 5 años
padre
commit
d7611ecff2

+ 24 - 0
SATHelper/SATHelper/MainFrm.cpp

@@ -17,6 +17,7 @@
 #include "SATHelper.h"
 
 #include "MainFrm.h"
+#include "SATHelperView.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -60,6 +61,13 @@ CMainFrame::CMainFrame() noexcept :m_trayIcon(IDR_MAINFRAME)
 	m_isNotify = TRUE;
 	m_bNoticeTray = TRUE;
 #endif
+
+	m_pDoc = NULL;
+	m_pActiveView = NULL;
+	for ( int i = 0; i < 10; i++ )
+	{
+		m_pViewIDE[i] = NULL;
+	}
 }
 
 CMainFrame::~CMainFrame()
@@ -260,6 +268,22 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	ModifyStyle(0, FWS_PREFIXTITLE);
 #endif
 
+#if 1 // 第一个视图;
+	CCreateContext context;
+	CChildFrame* pChildFrame = new CChildFrame();
+	context.m_pLastView = NULL;
+	context.m_pCurrentFrame = this;
+	context.m_pCurrentDoc = m_pDoc;
+	context.m_pNewViewClass = RUNTIME_CLASS(CSATHelperView);
+	context.m_pNewDocTemplate = m_pDoc->GetDocTemplate();
+	if (pChildFrame->LoadFrame(100, WS_MAXIMIZE | WS_OVERLAPPEDWINDOW /*WS_CHILDWINDOW*/, this, &context))
+	{
+		pChildFrame->ShowWindow(SW_SHOWMAXIMIZED);
+		pChildFrame->InitialUpdateFrame(context.m_pCurrentDoc, TRUE);
+		pChildFrame->MDIActivate();
+	}
+#endif
+
 	return 0;
 }
 

+ 5 - 0
SATHelper/SATHelper/MainFrm.h

@@ -19,6 +19,8 @@
 #include "IRControlWnd.h"
 #include "CalendarBar.h"
 #include "Resource.h"
+#include "SATHelperDoc.h"
+#include "ChildFrm.h"
 //////////////////////////////////////////////////////////////////////////
 #include "TrayIcon.h"
 #define USE_TRAYICON 1
@@ -39,6 +41,9 @@ public:
 
 // 特性
 public:
+	CSATHelperDoc* m_pDoc;
+	CFormView* m_pActiveView;
+	CChildFrame* m_pViewIDE[10];
 
 // 操作
 public:

+ 9 - 20
SATHelper/SATHelper/SATHelper.cpp

@@ -81,6 +81,8 @@ CIOCPModel g_iocp;
 HANDLE g_hMutex = NULL;	// 全局互斥量;
 ULONG_PTR CSATHelperApp::m_gdiplusToken = 0;
 
+// CMainFrame* g_pMainFrame = NULL;
+
 BOOL CSATHelperApp::InitInstance()
 {
 	// 如果一个运行在 Windows XP 上的应用程序清单指定要
@@ -190,7 +192,12 @@ BOOL CSATHelperApp::InitInstance()
 
 	// 创建主 MDI 框架窗口
 	CMainFrame* pMainFrame = new CMainFrame;
-	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
+	if ( !pMainFrame )
+		return FALSE;
+
+	// 创建模板类的文档对象;
+	pMainFrame->m_pDoc = (CSATHelperDoc*)pDocTemplate->CreateNewDocument();
+	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
 	{
 		delete pMainFrame;
 		return FALSE;
@@ -204,9 +211,7 @@ BOOL CSATHelperApp::InitInstance()
 	cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
 #endif
 	ParseCommandLine(cmdInfo);
-
-
-
+	
 	// 调度在命令行中指定的命令。  如果
 	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
 	if (!ProcessShellCommand(cmdInfo))
@@ -215,22 +220,6 @@ BOOL CSATHelperApp::InitInstance()
 	pMainFrame->ShowWindow(m_nCmdShow);
 	pMainFrame->UpdateWindow();
 	
-#if 1
-	CCreateContext context;
-	CChildFrame* pChildFrame = new CChildFrame();	
-	context.m_pCurrentDoc = pDocTemplate->CreateNewDocument();
-	context.m_pNewDocTemplate = pDocTemplate;
-	context.m_pLastView = NULL;
-	context.m_pNewViewClass = RUNTIME_CLASS(CSATHelperView);
-	//pDocTemplate->CreateNewFrame(context.m_pCurrentDoc, NULL);
-	if (pChildFrame->LoadFrame(100, WS_MAXIMIZE | WS_CHILDWINDOW, pMainFrame, &context))
-	{
-		pChildFrame->ShowWindow(SW_SHOWMAXIMIZED);
-		pChildFrame->InitialUpdateFrame(context.m_pCurrentDoc, TRUE);
-		pChildFrame->MDIActivate();
-	}
-#endif
-
 	return TRUE;
 }