当前位置:首页 > VC++电脑游戏飞机大战的开发与设计(含源文件)
学位论文
BEGIN_MESSAGE_MAP(CMyDlg, CDialog) //{{AFX_MSG_MAP(CMyDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT()
ON_WM_QUERYDRAGICON() ON_WM_DESTROY() ON_WM_TIMER() ON_WM_ERASEBKGND() ON_WM_KEYDOWN() //}}AFX_MSG_MAP ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP()
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// // CMyDlg message handlers
BOOL CMyDlg::OnInitDialog() { CDialog::OnInitDialog();
// Add \
// IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
44
学位论文
if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING,
IDM_ABOUTBOX,
strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
// TODO: Add extra initialization here this->SetWindowText(_T(\飞机大战\ InitData();
m_uTimer = SetTimer(1,30,NULL); srand((unsigned)time(NULL)); InitUserDC(); DrawContent();
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal();
}
45
学位论文
}
else { }
CDialog::OnSysCommand(nID, lParam);
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CMyDlg::OnPaint() {
/* if (IsIconic()) 0);
} else {
CDialog::OnPaint();
46
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(),
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
学位论文
}*/
CPaintDC dc(this); CRect rc; GetClientRect(rc);
dc.BitBlt(0,0,rc.Width(),rc.Height(),&m_dcMem,0,0,SRCCOPY);
}
// The system calls this to obtain the cursor to display while the user drags // the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon;
}
void CMyDlg::OnDestroy() { CDialog::OnDestroy();
// TODO: Add your message handler code here KillTimer(m_uTimer); DeleteUserDC(); delete[] pMEPOINT; delete[] pFLIVVERPOINT; delete[] pFLIVVER2POINT; delete[] pFLIVVER3POINT;
}
void CMyDlg::OnTimer(UINT nIDEvent) {
m_bgPlace = ++m_bgPlace % 601;
47
共分享92篇相关文档