MM.cpp
上传用户:jyxwjx
上传日期:2020-03-13
资源大小:221k
文件大小:7k
- // MM.cpp : 览侩 橇肺弊伐俊 措茄 努贰胶 悼累阑 沥狼钦聪促.
- //
- #include "stdafx.h"
- #include "MM.h"
- #include "MainFrm.h"
- #include "ChildFrm.h"
- #include "MMDoc.h"
- #include "MMView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CMMApp
- BEGIN_MESSAGE_MAP(CMMApp, 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)
- END_MESSAGE_MAP()
- // CMMApp 积己
- CMMApp::CMMApp()
- {
- // TODO: 咯扁俊 积己 内靛甫 眠啊钦聪促.
- // InitInstance俊 葛电 吝夸茄 檬扁拳 累诀阑 硅摹钦聪促.
- m_infoMonitor.nMonitor = 1;
- m_infoMonitor.nWidthVirtual = 1024;
- m_infoMonitor.nHeightVirtual = 768;
- m_infoMonitor.nWidth = 1024;
- m_infoMonitor.nHeight = 768;
- m_infoMonitor.nBitPerPixel= 16;
- m_infoMonitor.nRefresh = 60;
- }
- // 蜡老茄 CMMApp 俺眉涝聪促.
- CMMApp theApp;
- // CMMApp 檬扁拳
- BOOL CMMApp::InitInstance()
- {
- // 览侩 橇肺弊伐 概聪其胶飘啊 ComCtl32.dll 滚傈 6 捞惑阑 荤侩窍咯 厚林倔 胶鸥老阑
- // 荤侩窍档废 瘤沥窍绰 版快, Windows XP 惑俊辑 馆靛矫 InitCommonControls()啊 鞘夸钦聪促.
- // InitCommonControls()甫 荤侩窍瘤 臼栏搁 芒阑 父甸 荐 绝嚼聪促.
- InitCommonControls();
- CWinApp::InitInstance();
- GetMonitorInformation();
- // OLE 扼捞宏矾府甫 檬扁拳钦聪促.
- if (!AfxOleInit())
- {
- AfxMessageBox(IDP_OLE_INIT_FAILED);
- return FALSE;
- }
- AfxEnableControlContainer();
- // 钎霖 檬扁拳
- // 捞甸 扁瓷阑 荤侩窍瘤 臼绊 弥辆 角青 颇老狼 农扁甫 临捞妨搁
- // 酒贰俊辑 鞘夸 绝绰 漂沥 檬扁拳 风凭阑 力芭秦具 钦聪促.
- // 秦寸 汲沥捞 历厘等 饭瘤胶飘府 虐甫 函版窍绞矫坷.
- // TODO: 捞 巩磊凯阑 雀荤 肚绰 炼流狼 捞抚苞 鞍篮
- // 利例茄 郴侩栏肺 荐沥秦具 钦聪促.
- SetRegistryKey(_T("肺拿 览侩 橇肺弊伐 付过荤俊辑 积己等 览侩 橇肺弊伐"));
- LoadStdProfileSettings(4); // MRU甫 器窃窍咯 钎霖 INI 颇老 可记阑 肺靛钦聪促.
- // 览侩 橇肺弊伐狼 巩辑 袍敲复阑 殿废钦聪促. 巩辑 袍敲复篮
- // 巩辑, 橇饭烙 芒 棺 轰 荤捞狼 楷搬 开且阑 钦聪促.
- CMultiDocTemplate* pDocTemplate;
- pDocTemplate = new CMultiDocTemplate(IDR_MMTYPE,
- RUNTIME_CLASS(CMMDoc),
- RUNTIME_CLASS(CChildFrame), // 荤侩磊 瘤沥 MDI 磊侥 橇饭烙涝聪促.
- RUNTIME_CLASS(CMMView));
- AddDocTemplate(pDocTemplate);
- // 林 MDI 橇饭烙 芒阑 父奠聪促.
- CMainFrame* pMainFrame = new CMainFrame;
- if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
- return FALSE;
- m_pMainWnd = pMainFrame;
- // 立固荤啊 乐阑 版快俊父 DragAcceptFiles甫 龋免钦聪促.
- // MDI 览侩 橇肺弊伐俊辑绰 m_pMainWnd甫 汲沥茄 饶 官肺 捞矾茄 龋免捞 惯积秦具 钦聪促.
- // 钎霖 夹 疙飞, DDE, 颇老 凯扁俊 措茄 疙飞临阑 备巩 盒籍钦聪促.
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // 疙飞临俊 瘤沥等 疙飞阑 叼胶菩摹钦聪促. 览侩 橇肺弊伐捞 /RegServer, /Register, /Unregserver 肚绰 /Unregister肺 矫累等 版快 FALSE甫 馆券钦聪促.
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
- // 林 芒捞 檬扁拳登菌栏骨肺 捞甫 钎矫窍绊 诀单捞飘钦聪促.
- pMainFrame->ShowWindow(m_nCmdShow);
- pMainFrame->UpdateWindow();
- return TRUE;
- }
- // 览侩 橇肺弊伐 沥焊俊 荤侩登绰 CAboutDlg 措拳 惑磊涝聪促.
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // 措拳 惑磊 单捞磐
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 瘤盔
- // 备泅
- protected:
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- END_MESSAGE_MAP()
- // 措拳 惑磊甫 角青窍扁 困茄 览侩 橇肺弊伐 疙飞涝聪促.
- void CMMApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- // CMMApp 皋矫瘤 贸府扁
- BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor,HDC hdcMonitor,LPRECT lprcMonitor,LPARAM dwData)
- {
- MONITORINFOEX mi;
- mi.cbSize=sizeof(MONITORINFOEX);
- GetMonitorInfo(hMonitor,&mi);
- theApp.m_infoMonitor.aryMonitors.Add(mi);
- return TRUE;
- }
- int CMMApp::GetMonitorInformation(void)
- {
- m_infoMonitor.nMonitor = ::GetSystemMetrics(SM_CMONITORS);
- XLOGOUT(">>GetMonitorInformation : SM_CMONITORS[%d]", m_infoMonitor.nMonitor);
- m_infoMonitor.bSameDisplayFormat = ::GetSystemMetrics(SM_SAMEDISPLAYFORMAT);
- XLOGOUT(">>GetMonitorInformation : SM_SAMEDISPLAYFORMAT[%s]", (m_infoMonitor.bSameDisplayFormat)?"TRUE":"FALSE");
-
- m_infoMonitor.rcVirtual.left=GetSystemMetrics(SM_XVIRTUALSCREEN);
- m_infoMonitor.rcVirtual.top=GetSystemMetrics(SM_YVIRTUALSCREEN);
- m_infoMonitor.rcVirtual.right=m_infoMonitor.rcVirtual.left+GetSystemMetrics(SM_CXVIRTUALSCREEN);
- m_infoMonitor.rcVirtual.bottom=m_infoMonitor.rcVirtual.top+GetSystemMetrics(SM_CYVIRTUALSCREEN);
- m_infoMonitor.nWidth = ::GetSystemMetrics(SM_CXSCREEN); // 葛聪磐狼 秦惑档 x
- XLOGOUT(">>GetMonitorInformation : SM_CXSCREEN[%d]", m_infoMonitor.nWidth);
- m_infoMonitor.nHeight = ::GetSystemMetrics(SM_CYSCREEN); // 葛聪磐狼 秦惑档 y
- XLOGOUT(">>GetMonitorInformation : SM_CYSCREEN[%d]", m_infoMonitor.nHeight);
- m_infoMonitor.nWidthVirtual = ::GetSystemMetrics(SM_CXVIRTUALSCREEN); // 啊惑葛聪磐狼 秦惑档 x
- XLOGOUT(">>GetMonitorInformation : SM_CXVIRTUALSCREEN[%d]", m_infoMonitor.nWidthVirtual);
- m_infoMonitor.nHeightVirtual = ::GetSystemMetrics(SM_CYVIRTUALSCREEN); // 啊惑葛聪磐狼 秦惑档 y
- XLOGOUT(">>GetMonitorInformation : SM_CYVIRTUALSCREEN[%d]", m_infoMonitor.nHeightVirtual);
-
- m_infoMonitor.nMegaPixel = (m_infoMonitor.nWidth * m_infoMonitor.nHeight)/(1000*1000);
- m_infoMonitor.nMegaPixel = max(1,m_infoMonitor.nMegaPixel);
-
- XLOGOUT(">>GetMonitorInformation : MegaPixel[%d]", m_infoMonitor.nMegaPixel);
- HDC hDC=NULL;
- hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
- if(hDC)
- {
- EnumDisplayMonitors(NULL,NULL,MonitorEnumProc,(LPARAM)hDC);
- m_infoMonitor.nBitPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
- XLOGOUT(">>GetMonitorInformation : BITSPIXEL[%d]", m_infoMonitor.nBitPerPixel);
- m_infoMonitor.nRefresh = GetDeviceCaps(hDC, VREFRESH);
- XLOGOUT(">>GetMonitorInformation : VREFRESH[%d]", m_infoMonitor.nRefresh);
- DeleteDC(hDC);
- }
- else
- {
- XLOGOUT_LASTERROR;
- return -1;
- }
- for(int i=0;i<m_infoMonitor.aryMonitors.GetCount();i++)
- {
- XLOGOUT("MONITORS[%d]",i);
- XLOGOUT("rcMonitor[%d,%d,%d,%d]",((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcMonitor.left,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcMonitor.top,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcMonitor.right,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcMonitor.bottom);
- XLOGOUT("rcWork[%d,%d,%d,%d]",((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcWork.left,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcWork.top,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcWork.right,
- ((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).rcWork.bottom);
- XLOGOUT("dwFlags[%d]",((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).dwFlags);
- XLOGOUT("szDevice[%s]",((MONITORINFOEX)m_infoMonitor.aryMonitors.GetAt(i)).szDevice);
- }
- return 0;
- }