www.gusucode.com > 3D风格的VC++拼图游戏编写范例源码程序 > 3D风格的VC++拼图游戏编写范例/PictureGame/PictureGame/PictureGame1Dlg.cpp
// PictureGame1Dlg.cpp : implementation file // Download by http://www.srcfans.com #include "stdafx.h" #include "PictureGame1.h" #include "PictureGame1Dlg.h" #include "mmsystem.h" #pragma comment(lib,"winmm.lib") #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}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 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) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPictureGame1Dlg dialog CPictureGame1Dlg::CPictureGame1Dlg(CWnd* pParent /*=NULL*/) : CDialog(CPictureGame1Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CPictureGame1Dlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPictureGame1Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPictureGame1Dlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP DDX_Control(pDX,IDC_STATIC1,m_Image[0]); DDX_Control(pDX,IDC_STATIC2,m_Image[1]); DDX_Control(pDX,IDC_STATIC3,m_Image[2]); DDX_Control(pDX,IDC_STATIC4,m_Image[3]); DDX_Control(pDX,IDC_STATIC5,m_Image[4]); DDX_Control(pDX,IDC_STATIC6,m_Image[5]); DDX_Control(pDX,IDC_STATIC7,m_Image[6]); DDX_Control(pDX,IDC_STATIC8,m_Image[7]); DDX_Control(pDX,IDC_STATIC9,m_Image[8]); DDX_Control(pDX,IDC_STATIC10,m_Image[9]); DDX_Control(pDX,IDC_STATIC11,m_Image[10]); DDX_Control(pDX,IDC_STATIC12,m_Image[11]); DDX_Control(pDX,IDC_STATIC13,m_Image[12]); DDX_Control(pDX,IDC_STATIC14,m_Image[13]); DDX_Control(pDX,IDC_STATIC15,m_Image[14]); DDX_Control(pDX,IDC_STATIC16,m_Image[15]); } BEGIN_MESSAGE_MAP(CPictureGame1Dlg, CDialog) //{{AFX_MSG_MAP(CPictureGame1Dlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_COMMAND(ID_PICTURE1, OnPicture1) ON_COMMAND(ID_PICTURE2, OnPicture2) ON_COMMAND(ID_PICTURE3, OnPicture3) ON_COMMAND(ID_PICTURE4, OnPicture4) ON_COMMAND(ID_EASY, OnEasy) ON_COMMAND(ID_KUNNAN, OnKunnan) ON_WM_CLOSE() ON_BN_CLICKED(IDC_STATIC1, OnStatic1) ON_BN_CLICKED(IDC_STATIC2, OnStatic2) ON_BN_CLICKED(IDC_STATIC3, OnStatic3) ON_BN_CLICKED(IDC_STATIC4, OnStatic4) ON_BN_CLICKED(IDC_STATIC5, OnStatic5) ON_BN_CLICKED(IDC_STATIC6, OnStatic6) ON_BN_CLICKED(IDC_STATIC7, OnStatic7) ON_BN_CLICKED(IDC_STATIC8, OnStatic8) ON_BN_CLICKED(IDC_STATIC9, OnStatic9) ON_BN_CLICKED(IDC_STATIC10, OnStatic10) ON_BN_CLICKED(IDC_STATIC11, OnStatic11) ON_BN_CLICKED(IDC_STATIC12, OnStatic12) ON_BN_CLICKED(IDC_STATIC13, OnStatic13) ON_BN_CLICKED(IDC_STATIC14, OnStatic14) ON_BN_CLICKED(IDC_STATIC15, OnStatic15) ON_BN_CLICKED(IDC_STATIC16, OnStatic16) ON_COMMAND(ID_OWNER, OnOwner) ON_WM_CREATE() ON_WM_TIMER() ON_COMMAND(ID_3D, On3d) ON_COMMAND(ID_FLAG, OnFlag) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPictureGame1Dlg message handlers BOOL CPictureGame1Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // 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); 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 pMainMenu=GetMenu(); //pkDC=new CDC; SetWindowPos(NULL,0,0,358,346,SWP_NOMOVE); SetTimer(10,1000,NULL); m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM|CCS_NODIVIDER,CRect(0,0,0,0),this,102); // m_wndStatusBar.SetParts(3,Strp); // m_wndStatusBar.SetText("Time con",1,0); OnBegin(); return TRUE; // return TRUE unless you set the focus to a control } void CPictureGame1Dlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } 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 CPictureGame1Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // 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); } else { CDialog::OnPaint(); SetImage(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CPictureGame1Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPictureGame1Dlg::OnRun(UINT nBitmapID, UINT nMenuID) { pSubMenu=pMainMenu->GetSubMenu(1); pSubMenu->CheckMenuItem(ID_PICTURE1,MF_UNCHECKED); pSubMenu->CheckMenuItem(ID_PICTURE2,MF_UNCHECKED); pSubMenu->CheckMenuItem(ID_PICTURE3,MF_UNCHECKED); pSubMenu->CheckMenuItem(ID_PICTURE4,MF_UNCHECKED); pSubMenu->CheckMenuItem(nMenuID,MF_CHECKED); count=0; IsLong=FALSE; CanCount=FALSE; IsRnd=FALSE; Advan=FALSE; bitmap.DeleteObject(); bitmap.LoadBitmap(nBitmapID); SetPos(); SetImage(); } void CPictureGame1Dlg::SetPos() { BITMAP bm; INT con,move; if (Advan==FALSE) { bitmap.GetObject(sizeof(BITMAP),&bm);//判断一下ADVAN是否为FALSE Width=bm.bmWidth; Height=bm.bmHeight; } if (Easy) { x=Width/3; y=Height/3; con=2; } else if (!Easy) { x=Width/4; y=Height/4; con=3; } if(IsLong) move=70;//判断一下是70还是0 else move=0; for (int i=0;i<=con;i++) { m_Image[i].SetWindowPos(NULL,x*i+move,0,0,0,SWP_NOSIZE); m_Image[i].SetWindowPos(NULL,0,0,x,y,SWP_NOMOVE); } for (int j=0;j<=con;j++) { m_Image[con+1+j].SetWindowPos(NULL,x*j+move,y,0,0,SWP_NOSIZE); m_Image[con+1+j].SetWindowPos(NULL,0,0,x,y,SWP_NOMOVE); } for (int k=0;k<=con;k++) { m_Image[(con+1)*2+k].SetWindowPos(NULL,x*k+move,2*y,0,0,SWP_NOSIZE); m_Image[(con+1)*2+k].SetWindowPos(NULL,0,0,x,y,SWP_NOMOVE); } if (!Easy) { for (int l=0;l<=3;l++) { m_Image[l+12].SetWindowPos(NULL,x*l+move,3*y,0,0,SWP_NOSIZE); m_Image[l+12].SetWindowPos(NULL,0,0,x,y,SWP_NOMOVE); CClientDC dc(&m_Image[l+12]); } } } void CPictureGame1Dlg::SetImage() { INT con; HANDLE picture; CRect rect(0,0,x,y); if (Advan==TRUE) { picture=hbitmap; } else if(Advan==FALSE) picture=bitmap;//判断是等于BITMAP还是HBITMAP if (Easy) con=2; else if (!Easy) con=3; for (int i=0;i<=con;i++) { CDC*pDC=new CDC; CClientDC dc(&m_Image[i]); pDC->CreateCompatibleDC(&dc); pDC->SelectObject(picture); dc.BitBlt(0,0,x,y,pDC,x*i,0,SRCCOPY); if (Style3d) dc.Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0)); else if(!Style3d) dc.DrawEdge(rect,EDGE_RAISED,BF_RECT); delete pDC; UpdateWindow(); } for (int j=0;j<=con;j++) { CClientDC dc(&m_Image[con+1+j]); CDC*pDC=new CDC; pDC->CreateCompatibleDC(&dc); pDC->SelectObject(picture); dc.BitBlt(0,0,x,y,pDC,x*j,y,SRCCOPY); if (Style3d) dc.Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0)); else if (!Style3d) dc.DrawEdge(rect,EDGE_RAISED,BF_RECT); delete pDC; UpdateWindow(); } for (int k=0;k<=con;k++) { CClientDC dc(&m_Image[(con+1)*2+k]); CDC*pDC=new CDC; pDC->CreateCompatibleDC(&dc); pDC->SelectObject(picture); dc.BitBlt(0,0,x,y,pDC,x*k,2*y,SRCCOPY); if (Style3d) dc.Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0)); else if (!Style3d) dc.DrawEdge(rect,EDGE_RAISED,BF_RECT); delete pDC; UpdateWindow(); } if (!Easy) for (int l=0;l<=3;l++) { CClientDC dc(&m_Image[l+12]); CDC*pDC=new CDC; pDC->CreateCompatibleDC(&dc); pDC->SelectObject(picture); dc.BitBlt(0,0,x,y,pDC,x*l,3*y,SRCCOPY); if(Style3d) dc.Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0)); else if (!Style3d) dc.DrawEdge(rect,EDGE_RAISED,BF_RECT); delete pDC; UpdateWindow(); } if (!IsRnd) { pSubMenu=pMainMenu->GetSubMenu(0); pSubMenu->EnableMenuItem(ID_HELP,MF_DISABLED|MF_GRAYED);//判断IsRnd是否为假 } // Rnd(); } void CPictureGame1Dlg::OnPicture1() { // TODO: Add your command handler code here OnRun(IDB_BITMAP1,ID_PICTURE1); if(MessageBox("看清楚了吗?",NULL,MB_OK)==IDOK) Rnd(); } void CPictureGame1Dlg::OnPicture2() { OnRun(IDB_BITMAP2,ID_PICTURE2); if(MessageBox("看清楚了吗?",NULL,MB_OK)==IDOK) Rnd(); // TODO: Add your command handler code here } void CPictureGame1Dlg::OnPicture3() { // TODO: Add your command handler code here OnRun(IDB_BITMAP3,ID_PICTURE3); if(MessageBox("看清楚了吗?",NULL,MB_OK)==IDOK) Rnd(); } void CPictureGame1Dlg::OnPicture4() { // TODO: Add your command handler code here OnRun(IDB_BITMAP4,ID_PICTURE4); if(MessageBox("看清楚了吗?",NULL,MB_OK)==IDOK) Rnd(); } void CPictureGame1Dlg::OnEasy() { // TODO: Add your command handler code here Easy=TRUE; } void CPictureGame1Dlg::OnKunnan() { // TODO: Add your command handler code here Easy=FALSE; } UINT CPictureGame1Dlg::MapRand(UINT nMax) { int nRand=rand(); float fMap=(float)nMax/RAND_MAX; float fRetVal=(float)nRand*fMap+0.5f; return (UINT)fRetVal; } void CPictureGame1Dlg::Rnd() { int xnum,ynum,level; UINT rand; if(Easy) level=8; else if(!Easy) level=15; WINDOWPLACEMENT wpnum,wp15; for (int a=0;a<=600;a++) { rand=MapRand(4); if (rand==1) for (int b=0;b<=level-1;b++) { m_Image[level].GetWindowPlacement(&wp15); m_Image[b].GetWindowPlacement(&wpnum); xnum=wpnum.rcNormalPosition.left; ynum=wpnum.rcNormalPosition.top; if (wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top &&wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left-x) { m_Image[b].SetWindowPos(NULL,xnum+x,ynum,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } } if(rand==2) for (int c=0;c<=level-1;c++) { m_Image[level].GetWindowPlacement(&wp15); m_Image[c].GetWindowPlacement(&wpnum); xnum=wpnum.rcNormalPosition.left; ynum=wpnum.rcNormalPosition.top; if (wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top &&wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left+x) { m_Image[c].SetWindowPos(NULL,xnum-x,ynum,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } } if (rand==3) for (int d=0;d<=level-1;d++) { m_Image[level].GetWindowPlacement(&wp15); m_Image[d].GetWindowPlacement(&wpnum); xnum=wpnum.rcNormalPosition.left; ynum=wpnum.rcNormalPosition.top; if (wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left&&wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top+y ) { m_Image[d].SetWindowPos(NULL,xnum,ynum-y,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } } if (rand==4) for (int e=0;e<=level-1;e++) { m_Image[level].GetWindowPlacement(&wp15); m_Image[e].GetWindowPlacement(&wpnum); xnum=wpnum.rcNormalPosition.left; ynum=wpnum.rcNormalPosition.top; if (wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left&&wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top-y ) { m_Image[e].SetWindowPos(NULL,xnum,ynum+y,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } } } if (Easy) m_Image[8].ShowWindow(SW_HIDE); else if (!Easy) { m_Image[8].ShowWindow(SW_SHOW); m_Image[15].ShowWindow(SW_HIDE); } pSubMenu=pMainMenu->GetSubMenu(0); pSubMenu->EnableMenuItem(ID_HELP,MF_ENABLED); IsRnd=TRUE; CanCount=TRUE; } void CPictureGame1Dlg::OnClose() { // TODO: Add your message handler code here and/or call default if (::MessageBox(m_hWnd,"你确定要退出游戏吗?","拼图游戏",MB_YESNO)==IDYES) {CDialog::OnClose(); } //CDialog::OnClose(); } void CPictureGame1Dlg::MoveImage(int num) { int xnum,ynum,level; //UINT rand; if(Easy) level=8; else if(!Easy) level=15; WINDOWPLACEMENT wpnum,wp15; m_Image[level].GetWindowPlacement(&wp15); m_Image[num].GetWindowPlacement(&wpnum); xnum=wpnum.rcNormalPosition.left; ynum=wpnum.rcNormalPosition.top; if (num!=level) { if (wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top &&wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left-x) { m_Image[num].SetWindowPos(NULL,xnum+x,ynum,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } if (wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top &&wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left+x) { m_Image[num].SetWindowPos(NULL,xnum-x,ynum,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } if (wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left&&wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top+y ) { m_Image[num].SetWindowPos(NULL,xnum,ynum-y,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } if (wpnum.rcNormalPosition.left==wp15.rcNormalPosition.left&&wpnum.rcNormalPosition.top==wp15.rcNormalPosition.top-y ) { m_Image[num].SetWindowPos(NULL,xnum,ynum+y,0,0,SWP_NOSIZE); m_Image[level].SetWindowPos(NULL,xnum,ynum,0,0,SWP_NOSIZE); } } } void CPictureGame1Dlg::OnStatic1() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(0); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic2() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(1); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic3() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(2); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic4() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(3); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic5() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(4); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic6() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(5); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic7() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(6); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic8() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(7); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic9() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(8); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic10() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(9); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic11() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(10); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic12() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(11); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic13() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(12); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic14() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(13); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic15() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(14); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnStatic16() { // TODO: Add your control notification handler code here if (IsRnd) MoveImage(15); else Rnd(); if(IsWin()) CanCount=FALSE; } void CPictureGame1Dlg::OnBegin() { IsRnd=FALSE; CanCount=FALSE; count=0; SetPos(); //Rnd(); IsWin(); } BOOL CPictureGame1Dlg::IsWin() { WINDOWPLACEMENT wp; int con,move; int win=0; if (IsLong) move=70; else move=0; if (Easy) con=2; else if(!Easy) con=3; for (int a=0;a<=con;a++) { m_Image[a].GetWindowPlacement(&wp); if(wp.rcNormalPosition.top==0&&wp.rcNormalPosition.left==x*a+move) win+=1; } for (int b=0;b<=con;b++) { m_Image[con+1+b].GetWindowPlacement(&wp); if(wp.rcNormalPosition.top==y&&wp.rcNormalPosition.left==x*b+move) win+=1; } if(win<3) return FALSE; for (int c=0;c<=con;c++) { m_Image[2*(con+1)+c].GetWindowPlacement(&wp); if(wp.rcNormalPosition.top==2*y&&wp.rcNormalPosition.left==x*c+move) win+=1; } if(win<5) return FALSE; if (!Easy) for (int d=0;d<=3;d++) { m_Image[12+d].GetWindowPlacement(&wp); if(wp.rcNormalPosition.top==3*y&&wp.rcNormalPosition.left==x*d+move) win+=1; } if(Easy&&win==9) { m_Image[8].ShowWindow(SW_SHOW); //m_wndStatusBar.SetText("祝贺你,拼出来拉!",0,0); sndPlaySound(MAKEINTRESOURCE(IDR_WAVE2),SND_RESOURCE|SND_ASYNC); if(count<=10) {if(MessageBox("这么快!你的人品很坚挺哦",NULL,MB_OK)==IDOK) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(10<count&&count<=60) {if(MessageBox("祝贺你,拼出来拉!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(60<count&&count<=300) {if(MessageBox("真慢,你有成为2B的潜质!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(300<count) {if(MessageBox("2的一B,才拼出来!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else ; return TRUE; } else if (!Easy&&win==16) { m_Image[8].ShowWindow(SW_SHOW); m_Image[15].ShowWindow(SW_SHOW); sndPlaySound(MAKEINTRESOURCE(IDR_WAVE2),SND_RESOURCE|SND_ASYNC); //m_wndStatusBar.SetText("祝贺你,拼出来拉!",0,0); if(count<=10) {if(MessageBox("这么快!你的人品很坚挺哦")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(10<count&&count<=60) {if(MessageBox("祝贺你,拼出来拉!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(60<count&&count<=300) {if(MessageBox("真慢,你有成为2B的潜质!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else if(300<count) {if(MessageBox("2的一B,才拼出来!")) sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP);} else { }; return TRUE; } else return FALSE; } void CPictureGame1Dlg::OnOwner() { // TODO: Add your command handler code here CFileDialog dlg(TRUE,NULL,NULL,NULL,"位图文件(*.bmp)|*.bmp"); INT Result=dlg.DoModal(); if (Result==IDOK) { count=0; CanCount=FALSE; IsRnd=FALSE; Advan=TRUE; hbitmap=(HBITMAP)::LoadImage(NULL,dlg.GetFileName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); BITMAP bm; ::GetObject(hbitmap,sizeof(HBITMAP),&bm); if (bm.bmWidth>=bm.bmHeight) { hbitmap=(HBITMAP)::LoadImage(NULL,dlg.GetFileName(),IMAGE_BITMAP,350,280,LR_LOADFROMFILE); Width=350; Height=280; IsLong=FALSE; } else if (bm.bmWidth<=bm.bmHeight) { hbitmap=(HBITMAP)::LoadImage(NULL,dlg.GetFileName(),IMAGE_BITMAP,200,310,LR_LOADFROMFILE); Width=200; Height=310; IsLong=TRUE; } SetPos(); SetImage(); if(MessageBox("看清楚了吗?",NULL,MB_OK)==IDOK) Rnd(); } else if(IDCANCEL==Result) return ; } int CPictureGame1Dlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here sndPlaySound(MAKEINTRESOURCE(IDR_WAVE1),SND_RESOURCE|SND_ASYNC|SND_LOOP); return 0; } void CPictureGame1Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default nIDEvent=10; CString m_temp="计时:"; CString a; if(CanCount==TRUE) count+=1; a.Format("%d",count); //TimeOn=(CString)(count); TimeOn=m_temp+""+a+"""秒"; m_wndStatusBar.SetText(TimeOn,0,0); CDialog::OnTimer(nIDEvent); } /*void CPictureGame1Dlg::OnStaticA() { // TODO: Add your control notification handler code here MessageBox("sgf"); }*/ void CPictureGame1Dlg::On3d() { // TODO: Add your command handler code here Style3d=TRUE; } void CPictureGame1Dlg::OnFlag() { // TODO: Add your command handler code here Style3d=FALSE; }