📄 cg50.cpp
字号:
// Cg50.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Cg50.h"
#include "MainFrm.h"
#include "Cg50Doc.h"
#include "Cg50View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int b1=1,b2=1,b3=1;
/////////////////////////////////////////////////////////////////////////////
// CCg50App
BEGIN_MESSAGE_MAP(CCg50App, CWinApp)
//{{AFX_MSG_MAP(CCg50App)
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()
/////////////////////////////////////////////////////////////////////////////
// CCg50App construction
CCg50App::CCg50App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCg50App object
CCg50App theApp;
/////////////////////////////////////////////////////////////////////////////
// CCg50App initialization
BOOL CCg50App::InitInstance()
{
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.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(0); // 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(CCg50Doc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CCg50View));
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->SetWindowPos(NULL,0,0,800,600,0);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CButton m_button1;
CButton m_button3;
CButton m_button2;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnButton2();
afx_msg void OnButton3();
virtual BOOL OnInitDialog();
afx_msg void OnButton1();
//}}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_BUTTON1, m_button1);
DDX_Control(pDX, IDC_BUTTON3, m_button3);
DDX_Control(pDX, IDC_BUTTON2, m_button2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_WM_SETCURSOR()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CCg50App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCg50App commands
BOOL CAboutDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
CRect rcButton1,rcButton2,rcButton3;
CPoint ptCursor;
CWnd *pStatic1=GetDlgItem(IDC_BUTTON1),*pStatic2=GetDlgItem(IDC_BUTTON2),*pStatic3=GetDlgItem(IDC_BUTTON3);
pStatic1->GetWindowRect (rcButton1);
pStatic2->GetWindowRect (rcButton2);
pStatic3->GetWindowRect (rcButton3);
GetCursorPos(&ptCursor);
if ((rcButton1.PtInRect (ptCursor))||(rcButton2.PtInRect (ptCursor))||(rcButton3.PtInRect (ptCursor)))
{
CWinApp *pApp=AfxGetApp();
HICON hIconBang=pApp->LoadCursor (IDC_CURSOR1);
SetCursor(hIconBang);
if ((rcButton1.PtInRect (ptCursor))&&(b1==1))
{m_button1.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP6)));
b1=2;}
if ((!rcButton1.PtInRect (ptCursor))&&(b1==2))
{m_button1.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP5)));
b1=1;}
if ((rcButton2.PtInRect (ptCursor))&&(b2==1))
{m_button2.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP2)));
b2=2;}
if ((!rcButton2.PtInRect (ptCursor))&&(b2==2))
{m_button2.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1)));
b2=1;}
if ((rcButton3.PtInRect (ptCursor))&&(b3==1))
{m_button3.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP4)));
b3=2;}
if ((!rcButton3.PtInRect (ptCursor))&&(b3==2))
{m_button3.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP3)));
b3=1;}
return true;
}
if ((!rcButton1.PtInRect (ptCursor))&&(b1==2))
{m_button1.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP5)));
b1=1;}
if ((!rcButton2.PtInRect (ptCursor))&&(b2==2))
{m_button2.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1)));
b2=1;}
if ((!rcButton3.PtInRect (ptCursor))&&(b3==2))
{m_button3.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP3)));
b3=1;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CAboutDlg::OnButton2()
{ShellExecute(m_hWnd,NULL,"mailto:zhangpo@263.net",NULL,NULL,SW_SHOWMAXIMIZED);
}
void CAboutDlg::OnButton3()
{
ShellExecute(m_hWnd,NULL,"mailTo:hua@cad.cs.tsinghua.edu.cn",NULL,NULL,SW_SHOWMAXIMIZED);
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_button1.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP5)));
m_button2.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1)));
m_button3.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP3)));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnButton1()
{
ShellExecute(m_hWnd,NULL,"http://166.111.4.20:2222/cgi/runcgi?passwd+testtitle_frame+00240013+90",NULL,NULL,SW_SHOWMAXIMIZED);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -