MainFrm.cpp 15.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面
// (“Fluent UI”)。该示例仅供参考,
// 用以补充《Microsoft 基础类参考》和
// MFC C++ 库软件随附的相关电子文档。
// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。
// 若要了解有关 Fluent UI 许可计划的详细信息,请访问
// http://go.microsoft.com/fwlink/?LinkId=238214。
//
// 版权所有(C) Microsoft Corporation
// 保留所有权利。

// MainFrm.cpp : CMainFrame 类的实现
//

#include "stdafx.h"
#include "MyReader-DUI-MFC.h"

#include "MainFrm.h"
#include "MyReader-DUI-MFCView.h"
#include "DuiMainFrame.h"
#include "SkinBuilder.h"
#include "AppConst.h"
#include "Util.h"
#include "LogFile.h"
#include "BookDal.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

//#pragma comment(lib, "checkver")
extern "C" __declspec(dllexport) int Check(LPTSTR lpszUpdatePath);


// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)

	BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
		ON_WM_CREATE()
		ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar)
		ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR, &CMainFrame::OnUpdateViewCaptionBar)
		ON_COMMAND(ID_TOOLS_OPTIONS, &CMainFrame::OnOptions)
		ON_WM_SIZE()
		//ON_MESSAGE(WM_UPDATE_BOOKS_IN_CLOUD, &CMainFrame::OnUpdateBooksInCloud)
		ON_MESSAGE(DOWNLOAD_BOOK_COMPLETE, &CMainFrame::OnDownloadComplete)
		ON_MESSAGE(WM_UPDATE_DATA_PROGRESS, &CMainFrame::OnUpdateDownloadPregress)
		ON_MESSAGE(WM_SET_SECURITYKEY, &CMainFrame::OnSetSecurityKey)
		
		ON_MESSAGE(WM_GET_RECALLED_BOOKS, &CMainFrame::OnGetRecalledBooksList)
		ON_MESSAGE(WM_DELETE_RECALLED_BOOKS, &CMainFrame::OnDeleteRecalledBooks)
		ON_MESSAGE(WM_GET_BOOK_LIST_END, &CMainFrame::OnGetNewBookListEnd)
		ON_MESSAGE(WM_UPDATEBOOKSHELF, &CMainFrame::OnUpdateBookShelf)
		ON_MESSAGE(WM_GET_BOOK_INTERNET_FAIL, &CMainFrame::OnInternetFail)
		ON_MESSAGE(WM_GET_BOOK_LIST_FAIL, &CMainFrame::OnGetNewBookListFAIL)
		
		ON_MESSAGE(WM_SET_DOWNLOAD_STATE, &CMainFrame::OnSetDownloadState)
		ON_MESSAGE(WM_WRITE_LOG, &CMainFrame::OnWriteLogMsg)
		ON_MESSAGE(WM_UPLOAD_LOG, &CMainFrame::OnUploadLogMsg)
		ON_MESSAGE(WM_USER_LOGIN_REDO, &CMainFrame::OnReloginMsg)
		ON_MESSAGE(WM_GET_SECURITYKEY_ERROR, &CMainFrame::OnGetSecurityKeyMsg)
		ON_MESSAGE(WM_USER_CANCEL_LOADINF_PRC, &CMainFrame::OnUserCancelLoadingProcess)
		
		//ON_MESSAGE(WM_MAIN_FORM_SHOW_CENTER, OnMyMessage)
		//ON_WM_NCHITTEST()
		ON_WM_SHOWWINDOW()
		ON_WM_DESTROY()
	END_MESSAGE_MAP()

	// CMainFrame 构造/析构

	CMainFrame::CMainFrame()
	{
		// TODO: 在此添加成员初始化代码
		m_hUpdateThread = NULL;
		m_pDownloadBooks = NULL;
		m_pDownloadHistoryBooks=NULL;
		DuiLib::CWkeWebkitUI::WkeWebkit_Init();
	}

	CMainFrame::~CMainFrame()
	{
		if (m_hUpdateThread != NULL)
		{
			DWORD dw = WaitForSingleObject(m_hUpdateThread, 1000);
			if (dw == WAIT_TIMEOUT)
				TerminateThread(m_hUpdateThread, (DWORD)-1);
		}
		
		if (m_pDownloadBooks != NULL)
		{
			delete m_pDownloadBooks;
			m_pDownloadBooks = NULL;
		}
		if (m_pDownloadHistoryBooks != NULL)
		{
			delete m_pDownloadHistoryBooks;
			m_pDownloadHistoryBooks = NULL;
		}
		if(m_pMsgBox!=NULL)
		{
			delete m_pMsgBox;
			m_pMsgBox =NULL;
		}

		DuiLib::CWkeWebkitUI::WkeWebkit_Shutdown();

		::CoUninitialize();
	}

	CMyReaderDUIMFCDoc* CMainFrame::GetDocument() // non-debug version is inline
	{
		CDocument * pDocument=GetActiveDocument();
		if (pDocument == NULL) return NULL;
		ASSERT(pDocument->IsKindOf(RUNTIME_CLASS(CMyReaderDUIMFCDoc)));
		return (CMyReaderDUIMFCDoc*)pDocument;
	}

	void CMainFrame::OnSize(UINT nType, int cx, int cy)
	{
		CFrameWndEx::OnSize(nType, cx, cy);

		m_pMainFrame->ResizeClient(cx,cy);
		/*if(m_pMainFrame!=NULL)
		{
		MoveWindow()
		}*/
		/*if(cx<10)
		{
		return;
		}
		//m_wndSplitter.ShowSplitter();
		m_wndSplitter.MoveWindow(0,0,cx,cy);
		m_wndSplitter.SetRowInfo(0, 87, 87);
		m_wndSplitter.SetRowInfo(1, cy-87, 0);

		m_wndSplitter.RecalcLayout();*/

		//m_wndSplitter.HideSplitter();
	}

	int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
	{
		//ModifyStyle( WS_CAPTION | WS_SYSMENU, 0, SWP_FRAMECHANGED );
		//ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
		if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
			return -1;

		PostMessage(WM_GET_RECALLED_BOOKS, 0, 0);//获取用户信息入口
		return 0;
	}

	BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
	{
		if( !CFrameWndEx::PreCreateWindow(cs) )
			return FALSE;
		// TODO: 在此处通过修改
		//  CREATESTRUCT cs 来修改窗口类或样式
		cs.style = WS_POPUP|0x20000;
		cs.dwExStyle&=~WS_EX_CLIENTEDGE;

		/*WS_OVERLAPPED  | WS_CAPTION | FWS_ADDTOTITLE
		| WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;*/
		//去掉菜单
		if(cs.hMenu!=NULL)
		{
			::DestroyMenu(cs.hMenu);
			cs.hMenu      =      NULL;
		}
		return TRUE;
	}

#ifdef _DEBUG
	void CMainFrame::AssertValid() const
	{
		CFrameWndEx::AssertValid();
	}

	void CMainFrame::Dump(CDumpContext& dc) const
	{
		CFrameWndEx::Dump(dc);
	}
#endif //_DEBUG

	// CMainFrame 消息处理程序

	void CMainFrame::OnViewCaptionBar()
	{
		m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW);
		RecalcLayout(FALSE);
	}

	void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI)
	{
		pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());
	}

	void CMainFrame::OnOptions()
	{
		CMFCRibbonCustomizeDialog *pOptionsDlg = new CMFCRibbonCustomizeDialog(this, &m_wndRibbonBar);
		ASSERT(pOptionsDlg != NULL);

		pOptionsDlg->DoModal();
		delete pOptionsDlg;
	}

	BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
	{
		CLogFile log;
		log.WriteLog(_T("MainFrame OnCreateClient Start!"));
		//DuiLib::CSkinBuilder::SetModuleName(_T("bookshelf"));
		//DuiLib::CPaintManagerUI::SetResourcePath(DuiLib::CPaintManagerUI::GetInstancePath()+_T("\\skin\\"));    // 指定duilib资源的路径,这里指定为和exe同目录
		HRESULT Hr = ::CoInitialize(NULL);
		if( FAILED(Hr) ) return FALSE;
		m_pMainFrame=new DuiLib::CDuiMainFrame(pContext);
		if(m_pMainFrame!=NULL)
		{
			m_pMainFrame->Create(*this, _T("DuiMainFrame"), UI_WNDSTYLE_CHILD, 0, 0, 0, 1024,768);
 			
			m_pMsgBox =new CDownFrame(this,1,4);
			m_pMsgBox->m_strFileName =L"loading-gif-w.gif";
 			m_pMsgBox->Create(LPCTSTR(IDD_DIALOG1),AfxGetMainWnd());
			m_pMainFrame->ShowWindow(SW_HIDE);
 			m_pMsgBox->ShowWindow(SW_SHOW);
		}
		log.WriteLog(_T("MainFrame OnCreateClient End!"));

		return TRUE;
	}

	BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
	{
		if (pMsg->message==WM_MAIN_FORM_SHOW_CENTER)
		{
			if (NULL!=m_pMainFrame )
			{
				m_pMainFrame->ShowInfoCenter();
			}
		}
		if (pMsg->message == WM_ACTION_OK)
		{
			ShowWindow(SW_SHOWNA);
		}



		return __super::PreTranslateMessage(pMsg);
	}

	void CMainFrame::UpdateUpdateComponent()
	{
		CString strPath = theApp.GetCurDir();

		CString strCheckOldName = strPath + _T("unzip_dll.dll");
		CString strCheckNewName = strPath + _T("unzip_dll_New.dll");
		UpdateOneComponent(strCheckOldName, strCheckNewName);
		
		CString strUpdateOldName = strPath + _T("学习精灵.exe");
		CString strUpdateNewName = strPath + _T("start_New.exe");
		UpdateOneComponent(strUpdateOldName, strUpdateNewName);
	}

	BOOL CMainFrame::UpdateOneComponent(CString strOldName, CString strNewName)
	{
		if (HDR_FileExist(strNewName))
		{
			if (_taccess(strOldName, 0) == 0)
			{
				if (DeleteFile(strOldName))
				{
					if (_taccess(strNewName, 0) == 0)
					{
						if (_trename(strNewName, strOldName) == 0)
							return TRUE;
					}
				}
			}
		}

		return FALSE;
	}


	/*LRESULT CMainFrame::OnMyMessage(WPARAM wParam, LPARAM lParam)
	{
	if (NULL!=m_pMainFrame )
	{
	m_pMainFrame->ShowInfoCenter();
	}
	return 0;
	}*/

void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
	CFrameWndEx::OnShowWindow(bShow, nStatus);

	// TODO: 在此处添加消息处理程序代码
	if (bShow)
	{
		//CMyReaderDUIMFCDoc* pDoc = GetDocument();
// 		if (pDoc == NULL)
// 			return;


		m_pMainFrame->UpdateBooks();
	}

}


void CMainFrame::OnDestroy()
{
	CFrameWndEx::OnDestroy();

	// TODO: 在此处添加消息处理程序代码
// 	if(m_pMainFrame!=NULL)
// 	{
// 		HWND hwnd = m_pMainFrame->m_hWnd;
// 		m_pMainFrame->Close(0);
// 		delete m_pMainFrame;
// 		m_pMainFrame=NULL;
// 	}
	//释放掉DuiLib
	/*if(m_pMainFrame!=NULL)
	{
		//m_pMainFrame->Close(0);
		//m_pMainFrame->Close();
		delete m_pMainFrame;
		m_pMainFrame=NULL;
	}*/
	
}

// HRESULT CMainFrame::OnUpdateBooksInCloud(WPARAM wParam, LPARAM lParam)
// {
// 	CMyReaderDUIMFCDoc* pDoc = GetDocument();
// 
// //	m_pMainFrame->UpdateBooks(pDoc->m_curCatalogId);
// 
// //	std::vector<CBookInfo> books = theApp.m_pDownloadBooks->GetBooksList();
// 	
// 	m_pMainFrame->UpdateBooks();
// 	m_pDownloadBooks->DownloadNewBooksFromCloud(this->m_hWnd);
// 	
// 
// 	return 0;
// }

HRESULT CMainFrame::OnDownloadComplete(WPARAM wParam, LPARAM lParam)
{
	int status = (int)lParam;

	if (status == 2)
	{
		// 开始下载
	}
	else if (status == 0)
	{
		// 下载中
		if (NULL!=wParam)
		{
			BSTR b = (BSTR)wParam;
			CString strBookId(b);
			SysFreeString(b);
		}

	//	m_pMainFrame->UpdateABookInShelf(strBookId);
		CMyReaderDUIMFCDoc* pDoc = GetDocument();
		m_pMainFrame->UpdateBooks();
	}
// 	else if(status==3)
// 	{
// 		//下载时先下目录
// 		m_pDownloadBooks->DownLoadAndAddCatalog2DB(m_pDownloadBooks->m_BookInfo->bookId,m_pDownloadBooks->m_hWnd);
// 		//下载时先下资源
// 		m_pDownloadBooks->DownLoadAndAddResource2DB(m_pDownloadBooks->m_BookInfo->bookId,m_pDownloadBooks->m_hWnd);
// 
// 	}

// 	else if (status == 1)
// 	{
// 		// 全部下载完成
// 		if (m_pDownloadExercise == NULL)
// 			m_pDownloadExercise = new CDownloadExercises(this->m_hWnd);
// 		m_pDownloadExercise->RecallExercises();
// 	}
// 	else if (status == 2)
// 	{
// 		// 下完一本
// 		if (m_pDownloadExercise == NULL)
// 			m_pDownloadExercise = new CDownloadExercises(this->m_hWnd);
// 		m_pDownloadExercise->DownloadExercises();
// 	}


	return 0;
}
HRESULT CMainFrame::OnSetSecurityKey(WPARAM wParam, LPARAM lParam)
{
	CMyReaderDUIMFCDoc* pDoc = GetDocument();
	CFunction fun;
	BSTR a = (BSTR)lParam;
	BSTR b = (BSTR)wParam;
	CString strBookId(a);
	CString strMsg(b);
	if (strBookId.GetLength() > 0)
		SysFreeString(a);
	if (strMsg.GetLength() > 0)
		SysFreeString(b);

	pDoc->m_pBookDal->SaveBookSecurityKeyInfo(strBookId,fun.UnicodeToAscii(strMsg));
	return 0;
}

HRESULT CMainFrame::OnUpdateDownloadPregress(WPARAM wParam, LPARAM lParam)
{

	CMyReaderDUIMFCDoc* pDoc = GetDocument();
//	m_pMainFrame->UpdateBooks(pDoc->m_curCatalogId);
	int id = (int)lParam;
	if ((int)wParam == -1)
	{
		//::PostMessage(this->m_hWnd, WM_WRITE_LOG, 0, (LPARAM)OP_DOWNLOAD_BOOK_DATA_PAUSE);

		return 0;
	}

	BSTR b = (BSTR)wParam;
	CString strMsg(b);
	if (strMsg.GetLength() > 0)
		SysFreeString(b);

	pDoc->UpdateBookInfo(id, strMsg);
	m_pMainFrame->UpdateBooks(FALSE);


	return 0;
}
HRESULT CMainFrame::OnUpdateBookShelf(WPARAM wParam, LPARAM lParam)
{

	
	m_pMainFrame->UpdateBooks(TRUE);

	return 0;
}
HRESULT CMainFrame::OnUserCancelLoadingProcess(WPARAM wParam, LPARAM lParam)
{
	if(m_pMainFrame->CustomMessageBox(STRING_MSG_CANCEL_LOADING_PRC,1,0))
	{
		m_pMainFrame->SendMessage(WM_CLOSE,0,0);
	}
	
	return 0;
}

HRESULT CMainFrame::OnGetRecalledBooksList(WPARAM wParam, LPARAM lParam)
{
	StartUpdateBooksFromCloud();
	return 0;
}

HRESULT CMainFrame::OnDeleteRecalledBooks(WPARAM wParam, LPARAM lParam)
{
	//Mark By Ray 2018-06-14
// 	m_Log.WriteLog(_T("OnDeleteRecalledBooks Start!"));
// 	int count = (int)wParam;
// 	if (count > 0)
// 	{
// 		m_pDownloadBooks->DeleteRecalledBooksLocal();
// 		m_Log.WriteLog(_T("OnDeleteRecalledBooks End 2!"));
// 		return 0;
// 	}
// 	else if (count == -1)
// 	{
// 		CMyReaderDUIMFCDoc* pDoc = GetDocument();
// 		m_pMainFrame->UpdateBooks(pDoc->m_curCatalogId);
// 	}

	StartUpdateBooksFromCloud();

	//m_Log.WriteLog(_T("OnDeleteRecalledBooks End 1!"));

	return 0;
}


int CMainFrame::StartDeleteRecalledBooks(){
	return 0;
}

void CMainFrame::StartUpdateBooksFromCloud()
{
	//m_Log.WriteLog(_T("StartUpdateBooksFromCloud Start!"));

	if (m_pDownloadBooks == NULL)
		m_pDownloadBooks = new CDownloadBooks(AfxGetMainWnd()->m_hWnd);


	m_pDownloadBooks->GetBooksInfoInCloud();
	//m_Log.WriteLog(_T("StartUpdateBooksFromCloud End!"));
}


LRESULT CMainFrame::OnSetDownloadState(WPARAM wParam, LPARAM lParam)
{
	int id = (int)wParam;
	Book_State iState = (Book_State)lParam;

	//m_Log.WriteLog(_T("OnSetDwonloadState Start %d"), id);

	if (m_pDownloadBooks == NULL)
		m_pDownloadBooks = new CDownloadBooks(AfxGetMainWnd()->m_hWnd);
	
	if (iState == Download_Doing)
	{
		m_pDownloadBooks->AddDownloadList(id);
	}
	else
	{
		m_pDownloadBooks->RemoveBookFromDownloadList(id);
	}

	//m_Log.WriteLog(_T("OnSetDwonloadState end"));

	return 0;
}


LRESULT CMainFrame::OnWriteLogMsg(WPARAM wParam, LPARAM lParam)
{
	/*if (g_hLogThread != INVALID_HANDLE_VALUE)
	{
		::PostThreadMessage(g_iLogThreadID, WM_WRITE_LOG_THREAD, wParam, lParam);
	}*/

	return 0;
}

LRESULT CMainFrame::OnUploadLogMsg(WPARAM wParam, LPARAM lParam)
{
	g_hUploadLogThread = g_clogManager.StartUploadLog();
	return 0;
}
LRESULT CMainFrame::OnGetSecurityKeyMsg(WPARAM wParam, LPARAM lParam)
{
	m_pMainFrame->CustomMessageBox(STRING_MSG_BOOK_SECURITYKEY_GET_ERR,2,0);
	return 0;
}
LRESULT CMainFrame::OnReloginMsg(WPARAM wParam, LPARAM lParam)
{
	//清除Token记录
	m_pMsgBox->ShowWindow(SW_HIDE);
	int status=(int)lParam;
	CUserDao dao;
	dao.DeleteUserToken();
	//////////////
	if(status==1)
		m_pMainFrame->CustomMessageBox(STRING_MSG_DATETIME_ERROR,2,0);
	else if(status==2)
		m_pMainFrame->CustomMessageBox(STRING_MSG_GET_USERINFO_ERR,2,0);
	else 
		m_pMainFrame->CustomMessageBox(STRING_MSG_LOGIN_TIMEOUT,2,0);
	m_pMainFrame->LogOut();
	return 0;
}
LRESULT CMainFrame::OnGetNewBookListFAIL(WPARAM wParam, LPARAM lParam)
{
	return 0;
}
LRESULT CMainFrame::OnInternetFail(WPARAM wParam, LPARAM lParam)
{
	
	m_pMainFrame->CustomMessageBox(STRING_MSG_NETWORK_BAD,2,0);
	return 0;
}
LRESULT CMainFrame::OnGetNewBookListEnd(WPARAM wParam, LPARAM lParam)
{
	m_pMainFrame->SetHeadImage();
	CMyReaderDUIMFCDoc* pDoc = GetDocument();
	CBookDal bookDal;



	//复合型资源
	///////////////////////
	theApp.m_h_CompoundResEvent[0]=CreateEvent(NULL,FALSE,TRUE,NULL);
	theApp.m_h_CompoundResEvent[1]=CreateEvent(NULL,TRUE,FALSE,NULL);
	theApp.m_pCompoundResource =new CCompoundResource(theApp.m_strPublicDB_Path);
	theApp.m_pCompoundResource->Start();
	////////////////////////


	pDoc->UpdateBookInfos();

	if(pDoc->m_bookInfos.size()>0)
	{
		for(int nNum=0;nNum<pDoc->m_bookInfos.size();nNum++)
		{
			CBookInfo bookinfo =pDoc->m_bookInfos.at(nNum);
			bookDal.CheckAndReUnzip(bookinfo.bookId);
		}
	}

	if(pDoc->m_oldbooklist.size()>0)
	{
		for(int nNum=0;nNum<pDoc->m_oldbooklist.size();nNum++)
		{
			CBookInfo bookinfo =pDoc->m_oldbooklist.at(nNum);
			bookDal.CheckAndReUnzip(bookinfo.bookId);
		}
	}

	
  //Add By Ray 2019-05-19 机构版不读取本地(带新增)
// 	if(pDoc->m_oldbooklist.size()==0)
// 	{
// 		m_pMsgBox->ShowWindow(SW_HIDE);
// 		m_pMainFrame->CustomMessageBox(_T("书籍数据获取失败,请重新登入"), 2,0);
// 		m_pMainFrame->LogOut();
// 		return 0;
// 		
// 	}

		m_pMainFrame->UpdateBooks();

	
	m_pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	////埋点////////
	theApp.m_EventLog.init();
	theApp.m_EventLog.SetLogEvent(EVENT_CURRENT_SHELF);
	theApp.m_EventLog.MakeJsonFormat();
	/////////////
	if(m_pMsgBox)
	{
	    m_pMsgBox->ShowWindow(SW_MINIMIZE);

 		delete m_pMsgBox;
 		m_pMsgBox =NULL;
	}
	//Add By Ray 2020-06-11
	m_pMainFrame->ShowBookShelfTab();


	//Add By Ray 2020-07-26



	// CloseHandle(m_h_thread);
	return 0;
}
void CMainFrame::CreateLoadMsgBox()
{
	m_pMsgBox =new CDownFrame(this,1,4);
	m_pMsgBox->m_strFileName =L"loading-gif-w.gif";
	m_pMsgBox->Create(LPCTSTR(IDD_DIALOG1),AfxGetMainWnd());
	m_pMsgBox->OnTimer(0);
	m_pMainFrame->ShowWindow(SW_HIDE);
	m_pMsgBox->ShowWindow(SW_SHOW);
}

void CMainFrame::CloseLoadMsgBox()
{
	if(m_pMsgBox)
	{
		m_pMsgBox->ShowWindow(SW_MINIMIZE);

		delete m_pMsgBox;
		m_pMsgBox =NULL;
	}
}