anywhere.cpp
上传用户:zhenhuadz
上传日期:2007-01-07
资源大小:1511k
文件大小:7k
源码类别:

远程控制编程

开发平台:

Visual C++

  1. // anywhere.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "anywhere.h"
  5. #include "MainFrm.h"
  6. #include "anywhereDoc.h"
  7. #include "anywhereView.h"
  8. //#include "SysInfo.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAnywhereApp
  16. BEGIN_MESSAGE_MAP(CAnywhereApp, CWinApp)
  17. //{{AFX_MSG_MAP(CAnywhereApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. //    DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard file based document commands
  23. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  24. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25. // Standard print setup command
  26. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  27. END_MESSAGE_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CAnywhereApp construction
  30. CAnywhereApp::CAnywhereApp()
  31. {
  32. // TODO: add construction code here,
  33. // Place all significant initialization in InitInstance
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // The one and only CAnywhereApp object
  37. CAnywhereApp theApp;
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CAnywhereApp initialization
  40. BOOL CAnywhereApp::InitInstance()
  41. {
  42. if (!AfxSocketInit())
  43. {
  44. AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  45. return FALSE;
  46. }
  47. AfxEnableControlContainer();
  48. // Standard initialization
  49. // If you are not using these features and wish to reduce the size
  50. //  of your final executable, you should remove from the following
  51. //  the specific initialization routines you do not need.
  52. #ifdef _AFXDLL
  53. Enable3dControls(); // Call this when using MFC in a shared DLL
  54. #else
  55. Enable3dControlsStatic(); // Call this when linking to MFC statically
  56. #endif
  57. // Change the registry key under which our settings are stored.
  58. // TODO: You should modify this string to be something appropriate
  59. // such as the name of your company or organization.
  60. CString reg;
  61. reg.LoadString(IDS_REGEDIT_ANYWHERE);
  62. SetRegistryKey(_T(reg));
  63. //写入注册表注册信息
  64. //LoadStdProfileSettings(6);  // Load standard INI file options (including MRU)
  65. // Register the application's document templates.  Document templates
  66. //  serve as the connection between documents, frame windows and views.
  67. CSingleDocTemplate* pDocTemplate;
  68. pDocTemplate = new CSingleDocTemplate(
  69. IDR_MAINFRAME,
  70. RUNTIME_CLASS(CAnywhereDoc),
  71. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  72. RUNTIME_CLASS(CAnywhereView));
  73. AddDocTemplate(pDocTemplate);
  74. // Parse command line for standard shell commands, DDE, file open
  75. CCommandLineInfo cmdInfo;
  76. ParseCommandLine(cmdInfo);
  77. // Dispatch commands specified on the command line
  78. if (!ProcessShellCommand(cmdInfo))
  79. return FALSE;
  80. // The one and only window has been initialized, so show and update it.
  81. m_pMainWnd->ShowWindow(SW_SHOW);
  82. m_pMainWnd->UpdateWindow();
  83. // OnFileNew();
  84. return TRUE;//!(m_pMainWnd == NULL);
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CAboutDlg dialog used for App About
  88. #include "reportctrl.h"
  89. class CAboutDlg : public CDialog
  90. {
  91. public:
  92. CAboutDlg();
  93. // Dialog Data
  94. //{{AFX_DATA(CAboutDlg)
  95. enum { IDD = IDD_ABOUTBOX };
  96. CReportCtrl m_rcAbout;
  97. //}}AFX_DATA
  98. // ClassWizard generated virtual function overrides
  99. //{{AFX_VIRTUAL(CAboutDlg)
  100. protected:
  101. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  102. //}}AFX_VIRTUAL
  103. // Implementation
  104. protected:
  105. void OnRvnItemDrawPreview(NMHDR *pNMHDR, LRESULT *pResult);
  106. //{{AFX_MSG(CAboutDlg)
  107. virtual BOOL OnInitDialog();
  108. //}}AFX_MSG
  109. DECLARE_MESSAGE_MAP()
  110. };
  111. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  112. {
  113. //{{AFX_DATA_INIT(CAboutDlg)
  114. //}}AFX_DATA_INIT
  115. }
  116. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  117. {
  118. CDialog::DoDataExchange(pDX);
  119. //{{AFX_DATA_MAP(CAboutDlg)
  120.     DDX_Control(pDX,IDC_REPORT,m_rcAbout);
  121. //}}AFX_DATA_MAP
  122. }
  123. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  124. //{{AFX_MSG_MAP(CAboutDlg)
  125. //}}AFX_MSG_MAP
  126. END_MESSAGE_MAP()
  127. // App command to run the dialog
  128. void CAnywhereApp::OnAppAbout()
  129. {
  130. CAboutDlg aboutDlg;
  131. aboutDlg.DoModal();
  132. }
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CAnywhereApp message handlers
  135. BOOL CAnywhereApp::PreTranslateMessage(MSG* pMsg) 
  136. {
  137.   CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
  138.   if (pFrame) {
  139.     if (pFrame->m_Framework.ProcessMessage(pMsg))
  140.       return TRUE;
  141.   }
  142. return CWinApp::PreTranslateMessage(pMsg);
  143. }
  144. void CAboutDlg::OnRvnItemDrawPreview(NMHDR *pNMHDR, LRESULT *pResult)
  145. {
  146. LPNMRVDRAWPREVIEW lpnmrvdp = (LPNMRVDRAWPREVIEW)pNMHDR;
  147. CDC dc;
  148. dc.Attach(lpnmrvdp->hDC);
  149. if(lpnmrvdp->nState&RVIS_SELECTED)
  150. dc.SetTextColor(::GetFocus()==m_rcAbout.m_hWnd ? GetSysColor(COLOR_HIGHLIGHTTEXT):GetSysColor(COLOR_HIGHLIGHT));
  151. else
  152. dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHT));
  153. lpnmrvdp->rect.left += 40;
  154. lpnmrvdp->rect.top += 2;
  155. lpnmrvdp->rect.bottom -= 2;
  156. CString str;
  157. switch(lpnmrvdp->iItem)
  158. {
  159. case 0: str = _T("An Outlook 98 SUPERGRID Control"); break;
  160. case 1: str = _T("You are free to use, distribute or modify the code as long as the copyright information is not removed or modified."); break;
  161. }
  162. dc.DrawText(str, &lpnmrvdp->rect, DT_LEFT|DT_END_ELLIPSIS|DT_WORDBREAK);
  163. dc.Detach();
  164. *pResult = FALSE;
  165. }
  166. BOOL CAboutDlg::OnInitDialog() 
  167. {
  168. CDialog::OnInitDialog();
  169. RVCOLUMN rvc;
  170. rvc.lpszText = "说明";
  171. rvc.iWidth = 100;
  172. m_rcAbout.DefineColumn(0, &rvc);
  173. rvc.lpszText = "详细资料";
  174. rvc.iWidth = 350;
  175. m_rcAbout.DefineColumn(1, &rvc);
  176. if(m_rcAbout.GetStyle()&RVS_SHOWHGRID)
  177. //m_rcAbout.ModifyStyle(RVS_SHOWCOLORALWAYS, 0);
  178.     m_rcAbout.ModifyStyle(RVS_SHOWHGRID, 0);
  179. else
  180. m_rcAbout.ModifyStyle(0,RVS_SHOWHGRID);
  181. if(m_rcAbout.GetStyle()&RVS_SHOWVGRID)
  182. m_rcAbout.ModifyStyle(RVS_SHOWVGRID, 0);
  183. else
  184. m_rcAbout.ModifyStyle(0, RVS_SHOWVGRID);
  185. if (m_rcAbout.GetStyle()&RVS_SHOWCOLORALWAYS)
  186. m_rcAbout.ModifyStyle(RVS_SHOWCOLORALWAYS,0);
  187. else m_rcAbout.ModifyStyle(0,RVS_SHOWCOLORALWAYS);
  188. m_rcAbout.ActivateColumn(0, 0);
  189. m_rcAbout.ActivateColumn(1, 1);
  190. m_rcAbout.InsertItem(0, _T("作者")); m_rcAbout.SetItemText(0, 1, _T("周睿,杨润华"));
  191. m_rcAbout.InsertItem(1, _T("Copyright")); m_rcAbout.SetItemText(1, 1, _T("Copyright (C) 2000 by 华睿 SoftArts StuDio"));
  192. m_rcAbout.InsertItem(2, _T("与我们联系")); m_rcAbout.SetItemText(2, 1, _T("SoftArts@Elong.com"));
  193. RVITEM rvi;
  194. rvi.iItem = 0;
  195. rvi.nMask = RVIM_PREVIEW;
  196. rvi.nPreview = 32;
  197. m_rcAbout.SetItem(&rvi);
  198. rvi.iItem = 1;
  199. m_rcAbout.SetItem(&rvi);
  200. return TRUE;  // return TRUE unless you set the focus to a control
  201.               // EXCEPTION: OCX Property Pages should return FALSE
  202. }