123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- #include "stdafx.h"
- #include "IDE.h"
- #include "MainFrm.h"
- #include "ChildFrm.h"
- #include "IDEDoc.h"
- #include "IDEView.h"
- #include "SysLib.h"
- #include ".\ide.h"
- #include "StartupDlg.h"
- #include "Login.h"
- #include "gooddc.h"
- #include "public.h"
- #include "md5class.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- extern CRITICAL_SECTION g_CSLimit;
- BEGIN_MESSAGE_MAP(CIDEApp, CWinApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
-
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
-
- ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
- ON_COMMAND(ID_APP_EXIT, OnAppExit)
- END_MESSAGE_MAP()
- CIDEApp::CIDEApp()
- {
-
-
- }
- CIDEApp theApp;
- CMainFrame *g_pMainFrm = NULL;
- HANDLE hMutex;
- BOOL CIDEApp::InitInstance()
- {
-
-
-
- CString StrName="Runner Monitor";
- hMutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,StrName);
- if(hMutex==NULL)
- {
- hMutex=::CreateMutex(NULL,NULL,StrName);
- }
- else
- {
- MessageBox(NULL,"运行器已经打开!","温馨提示",MB_ICONINFORMATION);
- return FALSE;
- }
- InitializeCriticalSection(&g_CSLimit);
- InitCommonControls();
- CoInitialize( NULL );
- CWinApp::InitInstance();
-
- if (!AfxOleInit())
- {
- AfxMessageBox(IDP_OLE_INIT_FAILED);
- return FALSE;
- }
- AfxEnableControlContainer();
-
-
-
-
-
-
-
- SetRegistryKey(g_strAppwizardCreateApp);
- LoadStdProfileSettings(4);
-
- GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);
- MTVERIFY( g_hRunObject = ::CreateEvent(
- NULL,
- TRUE,
- 0,
- 0 ));
-
- GetSysData();
- g_Login();
- GetResourceString();
- CStartupDlg dlg;
- dlg.Create(IDD_STARTUP);
- char* lpBmpFile = "Bitmap\\home.bmp";
- BITMAPFILEHEADER bf;
- BITMAPINFOHEADER bi;
- FILE* fp = fopen(lpBmpFile,"rb");
- if (fp)
- {
- fread(&bf,sizeof(bf),1,fp);
- fread(&bi,sizeof(bi),1,fp);
- fclose(fp);
- int nCX = GetSystemMetrics(SM_CXSCREEN);
- int nCY = GetSystemMetrics(SM_CYSCREEN);
- int nW = bi.biWidth;
- int nH = bi.biHeight;
- dlg.MoveWindow((nCX-nW)/2,(nCY-nH)/2,nW,nH);
- }
- dlg.ShowWindow(TRUE);
- CDC* pDC = dlg.GetDC();
- CRect rect;
- dlg.GetClientRect(rect);
- int screenx=GetSystemMetrics(SM_CXSCREEN);
- int screeny=GetSystemMetrics(SM_CYSCREEN);
- DisplayBMP(pDC, 0, 0, rect.Width(), rect.Height(), lpBmpFile, FALSE);
- dlg.ReleaseDC(pDC);
- Sleep(3000);
- dlg.ShowWindow(FALSE);
-
-
- CMultiDocTemplate* pDocTemplate;
- pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,
- RUNTIME_CLASS(CIDEDoc),
- RUNTIME_CLASS(CChildFrame),
- RUNTIME_CLASS(CIDEView));
- AddDocTemplate(pDocTemplate);
-
- CMainFrame* pMainFrame = new CMainFrame;
- pMainFrame->m_pDoc = (CIDEDoc *)pDocTemplate->CreateNewDocument();
- if ( !pMainFrame )
- {
- MessageBox(NULL,"pMainFrame == NULL", g_strTip, MB_ICONWARNING);
- return FALSE;
- }
- if ( !pMainFrame->LoadFrame(IDR_MAINFRAME) )
- {
- MessageBox(NULL,"资源文件不对1", g_strTip, MB_ICONWARNING);
- return FALSE;
- }
- m_pMainWnd = pMainFrame;
-
-
-
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
-
- cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
- if (!ProcessShellCommand(cmdInfo))
- {
- MessageBox(NULL,"资源文件不对2", g_strTip, MB_ICONWARNING);
- return FALSE;
- }
-
- m_pMainWnd->SetWindowText(g_strStoneuIspcms);
- pMainFrame->ShowWindow(m_nCmdShow);
-
-
-
-
- pMainFrame->UpdateWindow();
- g_pMainFrm = pMainFrame;
- return TRUE;
- }
- int CIDEApp::ExitInstance()
- {
-
- GdiplusShutdown( m_gdiplusToken );
- if( g_hRunObject )
- MTVERIFY( SetEvent( g_hRunObject ) );
- if(g_hLangDLL)
- {
- AfxFreeLibrary(g_hLangDLL);
- }
-
-
- GdiplusShutdown(m_gdiplusToken);
-
- ::CloseHandle( hMutex );
- hMutex = NULL;
- DeleteCriticalSection( &g_CSLimit );
- CoUninitialize();
- return CWinApp::ExitInstance();
- }
- void CIDEApp::OnAppExit()
- {
-
- CMainFrame *pMainFrm=(CMainFrame*)m_pMainWnd;
- pMainFrm->m_nViewCount = 0;
- pMainFrm->OnSuperEnd();
- }
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX);
-
- protected:
- DECLARE_MESSAGE_MAP()
- public:
- virtual BOOL OnInitDialog();
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CString str;
- str.Format("【ver:%s】",g_strVersion );
- GetDlgItem(IDC_STA_VERSION)->SetWindowText(str);
- return TRUE;
-
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- END_MESSAGE_MAP()
- void CIDEApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- int CIDEApp::IsNoDlgLogin()
- {
- int nRet = -1;
- CHAR strFile[MAX_FILE_LENGTH + 1] = "";
- wsprintf(strFile, "%s\\set.ini", g_strDirectory);
- char RUN[MAX_PATH] = {0};
- memset(RUN, 0, sizeof(RUN));
-
-
-
-
-
-
-
- if( g_iAutoRunSystem==0 )
- return nRet;
- GetPrivateProfileString("User", "UserID","", g_strLoginUserID,sizeof(g_strLoginUserID), strFile );
- memset(g_strDefaultUserID, 0, sizeof(g_strDefaultUserID) );
- strcpy(g_strDefaultUserID, g_strLoginUserID);
- GetPrivateProfileString("User", "UserPwd","", g_strLoginPwd,sizeof(g_strLoginPwd), strFile );
- memset(g_strDefaultUserPwd, 0, sizeof(g_strDefaultUserPwd) );
- strcpy(g_strDefaultUserPwd, g_strLoginPwd);
- CString sUserID,sUserPwd;
- sUserID = g_strLoginUserID;
- sUserPwd = g_strLoginPwd;
- if( sUserID=="" || sUserPwd=="" )
- return nRet;
-
- char Path[_MAX_PATH] = {0};
- strcat(Path, g_strDirectory);
- strcat(Path,"\\");
- strcat(Path, _PROJECTDIR);
- strcat(Path,"\\");
- strcat(Path, "runpara.ini");
-
- if ( GetPrivateProfileString("RUNPARA", "STARTRUN","",RUN, 10, Path) != 0)
- {
- g_bStartRun = (RUN[0] == '1' ? true:false);
- }
- if ( GetPrivateProfileString("RUNPARA", "FULLSCREEN","",RUN, 10, Path) != 0)
- {
- g_bFullScreen = RUN[0] == '1' ? true:false;
- }
- CMD5 md5;
- md5.setPlainText( (char *)(LPCTSTR)sUserPwd );
- if( ( ( strcmp(g_strDefaultUserPwd, "") != 0 ) && (strcmp(g_strLoginUserID, (char*)(LPCTSTR)sUserID) != 0 ) ) ||
- ( strcmp(g_strDefaultUserPwd, "") == 0 ) ||
- (strcmp(g_strLoginUserID, (char*)(LPCTSTR)sUserID) != 0 ) ||
- ( strcmp(g_strDefaultUserPwd, sUserPwd) != 0 ) ||
- (strcmp(g_strLoginUserID, "") == 0) )
- {
- sUserPwd = CString(md5.getMD5Digest());
- }
- return 1;
- }
|