123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 |
- // IDE.cpp : 定义应用程序的类行为。
- //
- #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"
- //#include "conv.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- extern CRITICAL_SECTION g_CSLimit;
- // CIDEApp
- 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()
- {
- // TODO: 在此处添加构造代码,
- // 将所有重要的初始化放置在 InitInstance 中
- }
- // 唯一的一个 CIDEApp 对象
- CIDEApp theApp;
- CMainFrame *g_pMainFrm = NULL;
- // CIDEApp 初始化
- HANDLE hMutex;
- BOOL CIDEApp::InitInstance()
- {
- // 如果一个运行在 Windows XP 上的应用程序清单指定要
- // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
- //则需要 InitCommonControls()。否则,将无法创建窗口。
- 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();
- //// 初始化 OLE 库
- if (!AfxOleInit())
- {
- AfxMessageBox(IDP_OLE_INIT_FAILED);
- return FALSE;
- }
- AfxEnableControlContainer();
- // 标准初始化
- // 如果未使用这些功能并希望减小
- // 最终可执行文件的大小,则应移除下列
- // 不需要的特定初始化例程
- // 更改用于存储设置的注册表项
- // TODO: 应适当修改该字符串,
- // 例如修改为公司或组织名
- SetRegistryKey(g_strAppwizardCreateApp);
- LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
- // START GDI+ SUB SYSTEM
- GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);
- MTVERIFY( g_hRunObject = ::CreateEvent(
- NULL, /* Security */
- TRUE, /* Manual event */
- 0, /* Clear on creation */
- 0 ));//"IDE::g_hRunObject") );
- //InitPrintQueue();
- 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), // 自定义 MDI 子框架
- RUNTIME_CLASS(CIDEView));
- AddDocTemplate(pDocTemplate);
- // 创建主 MDI 框架窗口
- 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;
- // 仅当具有后缀时才调用 DragAcceptFiles
- // 在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生
- // 分析标准外壳命令、DDE、打开文件操作的命令行
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // 调度在命令行中指定的命令。如果
- // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
- 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);
- //if( g_bFullScreen )
- //{
- // m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);//窗口最大化 关于全屏
- //}
- pMainFrame->UpdateWindow();
- g_pMainFrm = pMainFrame;
- return TRUE;
- }
- int CIDEApp::ExitInstance()
- {
- // TODO: 在此添加专用代码和/或调用基类
- GdiplusShutdown( m_gdiplusToken );
- if( g_hRunObject )
- MTVERIFY( SetEvent( g_hRunObject ) );
- if(g_hLangDLL)
- {
- AfxFreeLibrary(g_hLangDLL);
- }
-
- // Shutdown GDI+ subystem
- GdiplusShutdown(m_gdiplusToken);
- //释放权限所占的内存
- ::CloseHandle( hMutex );
- hMutex = NULL;
- DeleteCriticalSection( &g_CSLimit );
- CoUninitialize();
- return CWinApp::ExitInstance();
- }
- void CIDEApp::OnAppExit()
- {
- // TODO: 在此添加命令处理程序代码
- CMainFrame *pMainFrm=(CMainFrame*)m_pMainWnd;
- pMainFrm->m_nViewCount = 0;
- pMainFrm->OnSuperEnd();
- }
- // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // 对话框数据
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
- // 实现
- 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();
- // TODO: 在此添加额外的初始化
- CString str;
- str.Format("【ver:%s】",g_strVersion );
- GetDlgItem(IDC_STA_VERSION)->SetWindowText(str);
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- END_MESSAGE_MAP()
- // 用于运行对话框的应用程序命令
- void CIDEApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- // CIDEApp 消息处理程序
- int CIDEApp::IsNoDlgLogin()//自动登录 -1:不是 0:失败 1:成功
- {
- 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 ( GetPrivateProfileString("User", "NoDlgLogin","",RUN, 10, strFile) != 0)
- //{
- // if( RUN[0] == '0' )
- // return nRet;
- //}
- //WritePrivateProfileString("User", "NoDlgLogin", "0", strFile);
- 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");
- //CString str;
- 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;
- }
|