www.pudn.com > russion_vc.zip > RussionDlg.cpp


// RussionDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Russion.h" 
#include "RussionDlg.h" 
#include "Dlg.h" 
 
//#include "Image.cpp" 
 
/* 
LPDIRECTDRAW            lpDD;           // DirectDraw object 
LPDIRECTDRAWSURFACE     lpDDSPrimary;   // DirectDraw primary surface 
LPDIRECTDRAWSURFACE     lpDDSBackBuffer;      // DirectDraw back buffer surface 
LPDIRECTDRAWSURFACE     lpDDSBack;        // DirectDraw offscreen surface 
LPDIRECTDRAWSURFACE     lpDDSPane;        // DirectDraw offscreen surface 
BOOL                    DestKey;    // Destination key capability 
DWORD                   dwGreen;            // Pure green 
DWORD                   dwBlue;             // Pure blue 
 
#define BUFFERS 1 
 
 
static BOOL InitImage( HWND  hwnd ); 
BOOL Fail( HWND hwnd,  char *szMsg ); 
static void ReleaseObjects( void ); 
BOOL LoadImage( LPDIRECTDRAWSURFACE lpDDS, LPSTR szImage ); 
void LoadAllImage(); 
void ReDrawBack(Player*); 
 
 
BOOL LoadImage( LPDIRECTDRAWSURFACE lpDDS, LPSTR szImage ) 
{ 
    HBITMAP         hbm; 
    HDC             hdcImage= NULL; 
    HDC             hdcSurf = NULL; 
    BOOL            bReturn = FALSE; 
    DDSURFACEDESC   ddsd; 
 
    ZeroMemory( &ddsd, sizeof( ddsd ) ); 
    ddsd.dwSize = sizeof( ddsd ); 
 
    if ( FAILED( lpDDS->GetSurfaceDesc( &ddsd ) ) ) 
	{ 
        goto Exit; 
    } 
 
    // If the pixel format isn't some flavor of RGB, we can't handle it. 
    if ( ( ddsd.ddpfPixelFormat.dwFlags != DDPF_RGB ) || 
         ( ddsd.ddpfPixelFormat.dwRGBBitCount < 16 ) ) 
 
    { 
        OutputDebugString( "Non-palettized RGB mode required.\n" ); 
        goto Exit;         
    } 
 
    // Try loading the image. 
    hbm = ( HBITMAP )LoadImage( NULL, szImage,  
            IMAGE_BITMAP, ddsd.dwWidth,  
            ddsd.dwHeight, LR_LOADFROMFILE | LR_CREATEDIBSECTION ); 
 
    if ( hbm == NULL )  
	{ 
        OutputDebugString( " Couldn't find the resource.\n" ); 
        goto Exit; 
    } 
 
    // Create a DC and select the image into it. 
    hdcImage = CreateCompatibleDC( NULL ); 
    SelectObject( hdcImage, hbm ); 
    
    // Get a DC for the surface. 
    if ( FAILED( lpDDS->GetDC( &hdcSurf ) ) ) 
	{ 
        OutputDebugString( "Couldn't get a DC.\n" ); 
        goto Exit; 
    } 
     
    // The BitBlt will perform format conversion as necessary. 
    if ( BitBlt( hdcSurf, 0, 0, ddsd.dwWidth, ddsd.dwHeight,  
        hdcImage, 0, 0, SRCCOPY ) == FALSE )  
	{ 
        OutputDebugString( "Blt failed.\n" ); 
        goto Exit; 
    } 
 
    // Success. 
    bReturn = TRUE; 
     
Exit: 
    // Clean up everything. 
    if ( hdcSurf ) 
        lpDDS->ReleaseDC( hdcSurf ); 
    if ( hdcImage ) 
        DeleteDC( hdcImage ); 
    if( hbm ) 
        DeleteObject( hbm ); 
 
    return bReturn; 
} 
 
 
static void ReleaseObjects( void ) 
{ 
    if ( lpDD != NULL ) 
    { 
        if ( lpDDSPrimary != NULL ) 
        { 
            if ( lpDDSBack != NULL ) 
            { 
                lpDDSBack->Release(); 
                lpDDSBack = NULL; 
            } 
            if ( lpDDSPane != NULL ) 
            { 
                lpDDSPane->Release(); 
                lpDDSPane = NULL; 
            } 
 
            lpDDSPrimary->Release(); 
            lpDDSPrimary = NULL; 
        } 
        lpDD->Release(); 
        lpDD = NULL; 
    } 
} 
 
BOOL Fail( HWND hwnd,  char *szMsg ) 
{ 
    ReleaseObjects(); 
	OutputDebugString( szMsg ); 
    DestroyWindow( hwnd ); 
    return FALSE; 
} 
 
 
static BOOL InitImage( HWND  hwnd ) 
{ 
 
    DDSURFACEDESC       ddsd; 
	DDPIXELFORMAT       ddpf; 
	DDSCAPS             ddscaps;    // Surface capabilities structure. 
    // Create the DirectDraw object -- we just need an IDirectDraw 
    // interface so we won't bother to query an IDirectDraw2 
    if ( FAILED( DirectDrawCreate( NULL, &lpDD, NULL ) ) ) 
	{ 
		return Fail( hwnd, "Couldn't create DirectDraw object.\n" ); 
	} 
 
	// Get exclusive mode 
    if FAILED( lpDD->SetCooperativeLevel( hwnd, 
                        DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ) ) 
	{ 
		return Fail( hwnd, "Couldn't set cooperative level.\n" ); 
	} 
 
    // Set the display mode. An RGB mode is required for this sample 
	if ( FAILED( lpDD->SetDisplayMode( 800, 600, 16 ) ) ) 
	{ 
		return Fail( hwnd, "Couldn't set display mode.\n" ); 
	} 
 
	// Create the primary surface 
	ddsd.dwSize = sizeof( ddsd ); 
    ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; 
    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |  
                            DDSCAPS_FLIP |  
                            DDSCAPS_COMPLEX | 
                            DDSCAPS_VIDEOMEMORY ; 
    ddsd.dwBackBufferCount = BUFFERS; 
   
    if ( FAILED( lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ) ) ) 
	{ 
        return Fail( hwnd, "Couldn't create primary surface." ); 
    } 
 
    // Get a pointer to the back buffer. 
    ddscaps.dwCaps = DDSCAPS_BACKBUFFER; 
    if ( FAILED( lpDDSPrimary->GetAttachedSurface( &ddscaps,  
		                                           &lpDDSBackBuffer ) ) ) 
	{ 
        return Fail( hwnd, "Couldn't find the back buffer.\n" ); 
    } 
 
 
	ddpf.dwSize = sizeof( ddpf ); 
 
	if ( FAILED( lpDDSPrimary->GetPixelFormat( &ddpf ) ) ) 
	{ 
		return Fail( hwnd, "Couldn't get the pixel format.\n" ); 
	} 
    dwGreen = ddpf.dwGBitMask; 
    dwBlue = ddpf.dwBBitMask; 
 
 
 
	ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |  
		           DDSD_WIDTH | DDSD_CKSRCBLT;  
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;  
    ddsd.dwHeight = 600;  
    ddsd.dwWidth = 800; 
    // Set the source color key to green. 
    ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = dwGreen; 
    ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = dwGreen; 
 
    if ( FAILED( lpDD->CreateSurface( &ddsd, &lpDDSBack, NULL ) ) ) 
	{ 
		return Fail( hwnd, "Couldn't create off-screen one.\n" ); 
	} 
 
	ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |  
		           DDSD_WIDTH | DDSD_CKSRCBLT;  
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;  
    ddsd.dwHeight = 24;  
    ddsd.dwWidth = 168; 
    // Set the source color key to green. 
    ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = dwGreen; 
    ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = dwGreen; 
 
    if ( FAILED( lpDD->CreateSurface( &ddsd, &lpDDSPane, NULL ) ) ) 
	{ 
		return Fail( hwnd, "Couldn't create off-screen one.\n" ); 
	} 
 
    // Create the third offscreen surface. 
 
 
    // Load our images. 
	if ( !LoadImage( lpDDSPrimary, "Back.bmp" ) )  
	{ 
        return Fail( hwnd, "Couldn't load the image.\n" ); 
    } 
 
    if ( !LoadImage( lpDDSBack, "Back.bmp" ) )  
	{ 
        return Fail( hwnd, "Couldn't load Back bmp.\n" ); 
    } 
 
    if ( !LoadImage( lpDDSPane, "Pane.bmp" ) )  
	{ 
        return Fail( hwnd, "Couldn't load Pane bmp.\n" ); 
    } 
 
	return TRUE; 
} 
 
void LoadAllImage() 
{ 
	if ( !LoadImage( lpDDSPrimary, "Back.bmp" ) )  
	{ 
//        return Fail( hwnd, "Couldn't load the image.\n" ); 
    } 
 
    if ( !LoadImage( lpDDSBack, "Back.bmp" ) )  
	{ 
//        return Fail( hwnd, "Couldn't load Back bmp.\n" ); 
    } 
 
    if ( !LoadImage( lpDDSPane, "Pane.bmp" ) )  
	{ 
//        return Fail( hwnd, "Couldn't load Pane bmp.\n" ); 
    } 
} 
 
 
void ReDrawBack(Player* CP) 
{ 
		 
	//画所有的方块 
//	int x=1,y=1; 
	for (int y=1;y<=MAXY;y++) 
	for (int x=1;x<=MAXX;x++) 
	{ 
		switch (CP->Back[x][y]) 
		{ 
		case 0 : 
			{ 
				int px,py; 
				CP->GetPoint(x,y,px,py); 
				CRect rect(px,py,px+24,py+24); 
				if(lpDDSPrimary->BltFast( px, py , lpDDSBack, &rect, 
										DDBLTFAST_WAIT )==DDERR_SURFACELOST) 
										  
				{ 
					lpDDSPrimary->Restore(); 
					LoadAllImage(); 
					lpDDSPrimary->BltFast( px, py, lpDDSBack, &rect, 
										DDBLTFAST_WAIT ); 
				} 
				//lpDDSPrimary->Flip( NULL, DDFLIP_WAIT ) ; 
 
				break; 
			} 
		default: 
			{ 
				int px,py; 
				CP->GetPoint(x,y,px,py); 
				CRect rect((CP->Back[x][y]-1)*24,0,CP->Back[x][y]*24,23); 
				if(lpDDSPrimary->BltFast( px, py, lpDDSPane, &rect, 
										DDBLTFAST_WAIT )==DDERR_SURFACELOST) 
										  
				{ 
					lpDDSPrimary->Restore(); 
					LoadAllImage(); 
					lpDDSPrimary->BltFast( px, py, lpDDSPane, &rect, 
										DDBLTFAST_WAIT ); 
				} 
				//lpDDSPrimary->Flip( NULL, DDFLIP_WAIT ) ; 
 
 
				break; 
			} 
 
		} 
	} 
	//使用GDI写出分数 
	lpDDSPrimary->Flip(NULL, DDFLIP_WAIT); 
} 
 
*/ 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CRussionDlg dialog 
 
CRussionDlg::CRussionDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CRussionDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CRussionDlg) 
		// 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 CRussionDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CRussionDlg) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CRussionDlg, CDialog) 
	//{{AFX_MSG_MAP(CRussionDlg) 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_WM_TIMER() 
	ON_WM_LBUTTONDOWN() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CRussionDlg message handlers 
 
BOOL CRussionDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// 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->MoveWindow(0,0,800,600); 
 
	Player1=new Player; 
	InitImage(); 
	speed=15; 
/*	EntranceDlg Edlg; 
	if (Edlg.DoModal()==IDCANCEL)  
	{ 
		CDialog::OnCancel(); 
		return FALSE; 
	} 
	 
*/	 
	SetTimer( 1/*自设ID号*/,500/*间隔0.1秒*/,NULL); 
	OnMenuFullscreen(); 
	CDC* pDC = GetDC(); 
					Player1->InitGame(); 
				ReDrawBack(Player1,pDC); 
 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
CRussionDlg::~CRussionDlg() 
{ 
	::KillTimer(this->m_hWnd, 1); 
	ReleaseImage(); 
	if(Player1!=NULL) delete Player1; 
} 
// 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 CRussionDlg::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(); 
	} 
 
	TRACE("\n		OnPaint\n"); 
	CWnd* pWnd=GetDlgItem(IDC_STATIC_1); 
	CDC* pDC=pWnd->GetDC(); 
	pDC->BitBlt(0,0,800,600,dcBk,0,0,SRCCOPY); 
	pWnd->ReleaseDC(pDC); 
 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CRussionDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CRussionDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	 
	CDialog::OnOK(); 
} 
 
void CRussionDlg::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	CDialog::OnCancel(); 
} 
 
 
 
 
 
BOOL CRussionDlg::PreTranslateMessage(MSG* pMsg)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	if(pMsg->message==WM_KEYDOWN) 
	{ 
		TRACE("\n %d %d  %d\n",pMsg->message,pMsg->lParam,pMsg->wParam); 
		TRACE("\nActive is %d \n",Player1->Active); 
		CWnd* pWnd=GetDlgItem(IDC_STATIC_1); 
		CDC* pDC=pWnd->GetDC(); 
		switch(pMsg->wParam) 
		{ 
		case 37: 
			{ 
				if(Player1->Active) 
				{ 
					// left 
					Player1->Left(); 
					ReDrawPane(Player1,pDC); 
				} 
				break; 
			} 
		case 40: 
			{ 
				if(Player1->Active) 
				{ 
					// down 
					if(!Player1->DownLine())  
					{ 
						//到底层 
						Player1->Stop(); 
						int n=Player1->Clear(); 
						Player1->InitNewPane(); 
					//	if(n==-1){ TRACE("\nClear Error!"); return 0;} 
					//	if (n==0) ReDrawPane(Player1,pDC); 
					//	else  
						this->ReDrawBack(Player1,pDC); 
						 
					} 
					ReDrawPane(Player1,pDC); 
				} 
				break; 
			} 
		case 39: 
			{ 
				if(Player1->Active) 
				{ 
					//right 
					Player1->Right(); 
					ReDrawPane(Player1,pDC); 
				} 
				break; 
			} 
		case 38: 
			{ 
				if(Player1->Active) 
				{ 
					//up 
					Player1->Turn(); 
					ReDrawPane(Player1,pDC); 
				} 
				break; 
			} 
		case 65: 
			{ 
				// 'a' 
				Player1->InitGame(); 
				ReDrawBack(Player1,pDC); 
				break; 
			} 
		default: 
			; 
		} 
		pWnd->ReleaseDC(pDC); 
	} 
 
	return CDialog::PreTranslateMessage(pMsg); 
} 
 
void CRussionDlg::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
//	Player1->DownStep(); 
//	Player1->ReDrawBack(); 
	CWnd* pWnd=GetDlgItem(IDC_STATIC_1); 
	CDC* pDC=pWnd->GetDC(); 
 
	if(Player1->Active) 
	{ 
		if(!Player1->DownLine())  
		{ 
			//到底层 
			Player1->Stop(); 
			int n=Player1->Clear(); 
			Player1->InitNewPane(); 
			this->ReDrawBack(Player1,pDC); 
			 
		} 
		ReDrawPane(Player1,pDC); 
	} 
	pWnd->ReleaseDC(pDC); 
	CDialog::OnTimer(nIDEvent); 
} 
 
/* 
void CRussionDlg::Begin() 
{ 
		Player1->InitNewPane(); 
} 
 
  */ 
 
void CRussionDlg::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CWnd* pWnd=GetDlgItem(IDC_STATIC_1); 
	CDC* pDC=pWnd->GetDC(); 
	pDC->BitBlt(0,0,800,600,dcBk,0,0,SRCCOPY); 
 
	Player1->InitGame(); 
	 
	{ 
		ReDrawPane(Player1,pDC); 
		Player1->DownStep(); 
//		Sleep(100); 
	} 
 
	pWnd->ReleaseDC(pDC); 
	CDialog::OnLButtonDown(nFlags, point); 
} 
 
void CRussionDlg::InitImage() 
{ 
	HBITMAP         hbm; 
 
	dcBk=new CDC; 
	dcBuf=new CDC; 
	dcPane=new CDC; 
 
	hbm = ( HBITMAP ) LoadImage( NULL, "Back.bmp",  
								IMAGE_BITMAP, 800, 600, LR_LOADFROMFILE | LR_CREATEDIBSECTION ); 
	if(hbm==NULL)  
	{ 
		TRACE("\nLoad image Error\n"); 
		return; 
	} 
	dcBk->CreateCompatibleDC( NULL ); 
    dcBk->SelectObject( hbm ); 
	if(hbm) DeleteObject( hbm ); 
 
 
	hbm = ( HBITMAP ) LoadImage( NULL, "Back.bmp",  
								IMAGE_BITMAP, 800, 600, LR_LOADFROMFILE | LR_CREATEDIBSECTION ); 
	if(hbm==NULL)  
	{ 
		TRACE("\nLoad image Error\n"); 
		return; 
	} 
	dcBuf->CreateCompatibleDC( NULL ); 
    dcBuf->SelectObject( hbm ); 
	if(hbm) DeleteObject( hbm ); 
 
	hbm = ( HBITMAP ) LoadImage( NULL, "Pane.bmp",  
							    IMAGE_BITMAP, 168, 24, LR_LOADFROMFILE | LR_CREATEDIBSECTION ); 
	if(hbm==NULL)  
	{ 
		TRACE("\nLoad image Error\n"); 
		return; 
	} 
 
	dcPane ->CreateCompatibleDC( NULL ); 
    dcPane->SelectObject( hbm ); 
	if(hbm) DeleteObject( hbm ); 
 
} 
 
void CRussionDlg::ReleaseImage() 
{ 
	if(dcBk!=NULL)  
	{ 
		::ReleaseDC(this->m_hWnd,dcBk->m_hDC); 
		delete dcBk; 
	} 
	if(dcBuf!=NULL)  
	{ 
		::ReleaseDC(this->m_hWnd,dcBuf->m_hDC); 
		delete dcBuf; 
	} 
	if(dcPane!=NULL)  
	{ 
		::ReleaseDC(this->m_hWnd,dcPane->m_hDC); 
		delete dcPane; 
	} 
 
} 
 
 
void CRussionDlg::ReDrawBack(Player* mPlayer,CDC* pDC) 
{ 
	 
	//画所有的方块 
	TRACE("\n画所有的方块\n"); 
	//	int x=1,y=1; 
	int px,py; 
	for (int y=1;y<=MAXY;y++) 
	for (int x=1;x<=MAXX;x++) 
	{ 
		switch (mPlayer->Back[x][y]) 
		{ 
		case 0 : 
			{ 
				mPlayer->GetPoint(x,y,px,py); 
				if(!dcBuf->BitBlt( px, py , 24,24,dcBk ,px,py,SRCCOPY)) 
				{ 
					return; 
				} 
				break; 
			} 
		default: 
			{ 
				int px,py; 
				mPlayer->GetPoint(x,y,px,py); 
				if(!dcBuf->BitBlt( px, py , 24,24,dcPane ,(mPlayer->Back[x][y]-1)*24,0,SRCCOPY))										  
				{ 
					return; 
				} 
				//lpDDSPrimary->Flip( NULL, DDFLIP_WAIT ) ; 
				break; 
			} 
		} 
	} 
 
	//画预告方块 
	px=(MAXX-2)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.x; 
	py=MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.y; 
	dcBuf->BitBlt(px,py,48,48,dcBk,px,py,SRCCOPY); 
	//px, py 在屏幕上象素位置 
	for( int i=0;i<=3;i++) 
	for( int j=0;j<=3;j++) 
		if(mPlayer->pre.matrix[i][j]!=0) 
			dcBuf->StretchBlt( px+i*12,py+j*12, 12,12,dcPane,(mPlayer->pre.list)*24,0,24,24,SRCCOPY); 
 
	//使用GDI写出分数 
	CString marks; 
	marks.Format("%d",mPlayer->Marks); 
	dcBuf->TextOut(350,60,marks); 
 
	pDC->BitBlt(50,108,240,432,dcBuf,50,108,SRCCOPY); 
	pDC->BitBlt(350,60,50,50,dcBuf,350,60,SRCCOPY); 
 
} 
 
void CRussionDlg::ReDrawPane(Player* mPlayer,CDC* pDC) 
{ 
	TRACE("\n重画一个方块\n"); 
	TRACE("\n方块 %d  ( %d , %d ) \n",mPlayer->mPane.list,mPlayer->mPane.x,mPlayer->mPane.y);  
	TRACE("now position (x: %d ,y: %d ,offset: %d ), last (x: %d ,y: %d ,offset: %d )\n",mPlayer->mPane.x,mPlayer->mPane.y,mPlayer->mPane.offset,mPlayer->mPane.lastx,mPlayer->mPane.lasty,mPlayer->mPane.lastoffset); 
	int px,py; 
 
//	mPlayer->GetPoint( mPlayer->mPane.lastx,mPlayer->mPane.lasty,px,py); 
	int i,j; 
	{ 
//		mPlayer->GetPoint( mPlayer->mPane.lastx,mPlayer->mPane.lasty,px,py); 
		px=(mPlayer->mPane.lastx-1)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.x; 
		py=(mPlayer->mPane.lasty-1)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.y+mPlayer->mPane.lastoffset*MICRO_PANE_LENGTH; 
		//px, py 在屏幕上象素位置 
		for( i=0;i<=3;i++) 
		for( j=0;j<=3;j++) 
			if(mPlayer->Back[i+mPlayer->mPane.lastx][j+mPlayer->mPane.lasty]!=0) 
				dcBuf->BitBlt(px+i*24,py+j*24, 24,24,dcPane,(mPlayer->Back[i+mPlayer->mPane.lastx][j+mPlayer->mPane.lasty]-1)*24,0,SRCCOPY); 
			else 
			dcBuf->BitBlt(px+i*24,py+j*24, 24,24,dcBk,px+i*24,py+j*24,SRCCOPY); 
		TRACE("\nClear"); 
		//清除上一次的痕迹 
 
		px=(mPlayer->mPane.x-1)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.x; 
		py=(mPlayer->mPane.y-1)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.y+mPlayer->mPane.offset*MICRO_PANE_LENGTH; 
		//px, py 在屏幕上象素位置 
		for( i=0;i<=3;i++) 
		for( j=0;j<=3;j++) 
			if(mPlayer->mPane.matrix[i][j]!=0) 
			dcBuf->BitBlt(px+i*24,py+j*24, 24,24,dcPane,(mPlayer->mPane.list)*24,0,SRCCOPY); 
		TRACE("\nDraw"); 
 
		px=(MAXX-2)*MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.x; 
		py=MICRO_PANE_LENGTH*PANE_LENGTH+mPlayer->lu.y; 
		//px, py 在屏幕上象素位置 
		for( int i=0;i<=3;i++) 
		for( int j=0;j<=3;j++) 
			if(mPlayer->pre.matrix[i][j]!=0) 
				dcBuf->StretchBlt( px+i*12,py+j*12, 12,12,dcPane,(mPlayer->pre.list)*24,0,24,24,SRCCOPY); 
 
		//画当前方块 
		pDC->BitBlt(mPlayer->lu.x,mPlayer->lu.y,240,432,dcBuf,mPlayer->lu.x,mPlayer->lu.y,SRCCOPY); 
//		pDC->BitBlt(0,0,800,600,dcBuf,0,0,SRCCOPY); 
 
	} 
} 
 
void CRussionDlg::ReDrawMarks(Player* mPlayer,CDC* pDC) 
{ 
	CString marks; 
	marks.Format("%d",mPlayer->Marks); 
	pDC->TextOut(350,60,marks); 
} 
 
void CRussionDlg::OnChangeEdit2()  
{ 
 
	// TODO: If this is a RICHEDIT control, the control will not 
	// send this notification unless you override the CDialog::OnInitDialog() 
	// function and call CRichEditCtrl().SetEventMask() 
	// with the ENM_CHANGE flag ORed into the mask. 
	 
	// TODO: Add your control notification handler code here 
	 
} 
 
 
void CRussionDlg::OnMenuFullscreen() 
{ 
	//全屏幕显示的处理函数 
	RECT rectDesktop; 
	WINDOWPLACEMENT wpNew; 
 
	if (m_bFullScreen) 
	{ 
		//全屏幕显示模式 
		//隐藏工具条和状态条 
//		m_wndStatusBar.ShowWindow(SW_HIDE); 
//		m_wndToolBar.ShowWindow(SW_HIDE); 
 
		//保存正常视图时的窗口位置信息以便恢复原来状态 
		GetWindowPlacement (&m_wpPrev); 
		m_wpPrev.length = sizeof m_wpPrev; 
 
		//调整RECT为新的窗口尺寸 
		::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop ); 
		::AdjustWindowRectEx(&rectDesktop, GetStyle()|WS_EX_APPWINDOW, FALSE, GetExStyle()); 
 
		//保存RECT以便OnGetMinMaxInfo()使用 
		m_FullScreenWindowRect = rectDesktop; 
 
		wpNew = m_wpPrev; 
		wpNew.showCmd = SW_SHOWNORMAL; 
		wpNew.rcNormalPosition = rectDesktop; 
 
		//生成新的工具条 
/*		m_wndFullScreenBar=new CToolBar; 
 
		if(!m_wndFullScreenBar->Create(this, CBRS_SIZE_DYNAMIC|CBRS_FLOATING) 
				|| !m_wndFullScreenBar->LoadToolBar(IDR_FULLSCREEN)) 
		{ 
			TRACE0("Failed to create toolbar\n"); 
			return; // fail to create 
		} 
 
		//不允许工具条停泊 
		m_wndFullScreenBar->EnableDocking(FALSE); 
		m_wndFullScreenBar->SetWindowPos(0,100,100,0,0,SWP_NOSIZE 
				|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW); 
		m_wndFullScreenBar->SetWindowText(_T("全屏幕显示")); 
		FloatControlBar(m_wndFullScreenBar, CPoint(100,100)); 
        m_bFullScreen=TRUE; 
*/ 
    } 
    else 
    { 
		//正常显示模式 
		//删除全屏幕工具条 
		m_wndFullScreenBar->DestroyWindow(); 
		delete m_wndFullScreenBar; 
 
		m_bFullScreen=FALSE; 
 
		//恢复工具条和状态条 
//		m_wndStatusBar.ShowWindow(SW_SHOWNORMAL); 
//		m_wndToolBar.ShowWindow(SW_SHOWNORMAL); 
		wpNew = m_wpPrev; 
    } 
 
	//设置窗口显示状态 
	SetWindowPlacement ( &wpNew ); 
} 
 
void CRussionDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{ 
	if (m_bFullScreen) 
	{ 
		lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height(); 
		lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y; 
		lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width(); 
		lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x; 
	} 
}