anywhere.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:7k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // anywhere.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "anywhere.h"
- #include "MainFrm.h"
- #include "anywhereDoc.h"
- #include "anywhereView.h"
- //#include "SysInfo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAnywhereApp
- BEGIN_MESSAGE_MAP(CAnywhereApp, CWinApp)
- //{{AFX_MSG_MAP(CAnywhereApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- // Standard print setup command
- ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CAnywhereApp construction
- CAnywhereApp::CAnywhereApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CAnywhereApp object
- CAnywhereApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CAnywhereApp initialization
- BOOL CAnywhereApp::InitInstance()
- {
- if (!AfxSocketInit())
- {
- AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
- return FALSE;
- }
- AfxEnableControlContainer();
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
- // Change the registry key under which our settings are stored.
- // TODO: You should modify this string to be something appropriate
- // such as the name of your company or organization.
- CString reg;
- reg.LoadString(IDS_REGEDIT_ANYWHERE);
- SetRegistryKey(_T(reg));
- //写入注册表注册信息
- //LoadStdProfileSettings(6); // Load standard INI file options (including MRU)
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(CAnywhereDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CAnywhereView));
- AddDocTemplate(pDocTemplate);
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
- // The one and only window has been initialized, so show and update it.
- m_pMainWnd->ShowWindow(SW_SHOW);
- m_pMainWnd->UpdateWindow();
- // OnFileNew();
- return TRUE;//!(m_pMainWnd == NULL);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- #include "reportctrl.h"
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- CReportCtrl m_rcAbout;
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- void OnRvnItemDrawPreview(NMHDR *pNMHDR, LRESULT *pResult);
- //{{AFX_MSG(CAboutDlg)
- virtual BOOL OnInitDialog();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- DDX_Control(pDX,IDC_REPORT,m_rcAbout);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // App command to run the dialog
- void CAnywhereApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnywhereApp message handlers
- BOOL CAnywhereApp::PreTranslateMessage(MSG* pMsg)
- {
- CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
- if (pFrame) {
- if (pFrame->m_Framework.ProcessMessage(pMsg))
- return TRUE;
- }
- return CWinApp::PreTranslateMessage(pMsg);
- }
- void CAboutDlg::OnRvnItemDrawPreview(NMHDR *pNMHDR, LRESULT *pResult)
- {
- LPNMRVDRAWPREVIEW lpnmrvdp = (LPNMRVDRAWPREVIEW)pNMHDR;
- CDC dc;
- dc.Attach(lpnmrvdp->hDC);
- if(lpnmrvdp->nState&RVIS_SELECTED)
- dc.SetTextColor(::GetFocus()==m_rcAbout.m_hWnd ? GetSysColor(COLOR_HIGHLIGHTTEXT):GetSysColor(COLOR_HIGHLIGHT));
- else
- dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHT));
- lpnmrvdp->rect.left += 40;
- lpnmrvdp->rect.top += 2;
- lpnmrvdp->rect.bottom -= 2;
- CString str;
- switch(lpnmrvdp->iItem)
- {
- case 0: str = _T("An Outlook 98 SUPERGRID Control"); break;
- 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;
- }
- dc.DrawText(str, &lpnmrvdp->rect, DT_LEFT|DT_END_ELLIPSIS|DT_WORDBREAK);
- dc.Detach();
- *pResult = FALSE;
- }
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- RVCOLUMN rvc;
- rvc.lpszText = "说明";
- rvc.iWidth = 100;
- m_rcAbout.DefineColumn(0, &rvc);
- rvc.lpszText = "详细资料";
- rvc.iWidth = 350;
- m_rcAbout.DefineColumn(1, &rvc);
- if(m_rcAbout.GetStyle()&RVS_SHOWHGRID)
- //m_rcAbout.ModifyStyle(RVS_SHOWCOLORALWAYS, 0);
- m_rcAbout.ModifyStyle(RVS_SHOWHGRID, 0);
- else
- m_rcAbout.ModifyStyle(0,RVS_SHOWHGRID);
- if(m_rcAbout.GetStyle()&RVS_SHOWVGRID)
- m_rcAbout.ModifyStyle(RVS_SHOWVGRID, 0);
- else
- m_rcAbout.ModifyStyle(0, RVS_SHOWVGRID);
- if (m_rcAbout.GetStyle()&RVS_SHOWCOLORALWAYS)
- m_rcAbout.ModifyStyle(RVS_SHOWCOLORALWAYS,0);
- else m_rcAbout.ModifyStyle(0,RVS_SHOWCOLORALWAYS);
- m_rcAbout.ActivateColumn(0, 0);
- m_rcAbout.ActivateColumn(1, 1);
- m_rcAbout.InsertItem(0, _T("作者")); m_rcAbout.SetItemText(0, 1, _T("周睿,杨润华"));
- m_rcAbout.InsertItem(1, _T("Copyright")); m_rcAbout.SetItemText(1, 1, _T("Copyright (C) 2000 by 华睿 SoftArts StuDio"));
- m_rcAbout.InsertItem(2, _T("与我们联系")); m_rcAbout.SetItemText(2, 1, _T("SoftArts@Elong.com"));
- RVITEM rvi;
- rvi.iItem = 0;
- rvi.nMask = RVIM_PREVIEW;
- rvi.nPreview = 32;
- m_rcAbout.SetItem(&rvi);
- rvi.iItem = 1;
- m_rcAbout.SetItem(&rvi);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }