Home > Back-end >  C do lianliankan finally appeared the problem of untreated abnormal 0 xc0000005: while reading posit
C do lianliankan finally appeared the problem of untreated abnormal 0 xc0000005: while reading posit

Time:12-09

//linkToLinkDlg. H: header file
//

# pragma once


//ClinkToLinkDlg dialog
The class ClinkToLinkDlg: public CDialogEx
{
//structure
Public:
PParent ClinkToLinkDlg (CWnd *=nullptr);//standard constructor
~ ClinkToLinkDlg ();
//data dialog
# ifdef AFX_DESIGN_TIME
Enum {IDD=IDD_LINKTOLINK_DIALOG};
# endif

Protected:
Virtual void DoDataExchange (CDataExchange * symbol;//support DDX/DDV
//draw the device handle
The CDC m_mem3DBkDC;//3 d equipment memory environment
CBitmap m_mem3DBkBmp;

The CDC m_memAnimalDC;
CBitmap m_memAnimalBmp;

The CDC m_MemDC;//the whole background
CBitmap m_memBitmap;


//a one-dimensional array used to store the state of the grid
Int * m_map;
//the location of the mouse click
Int m_nX1;
Int m_nY1;
//map of row and column
Int m_nRow;
Int m_nCol;
Void GameDraw * pDC (CDC);
//implementation
Protected:
HICON m_hIcon;
Void StartNewGame ();
//the generated message mapping function
Virtual BOOL OnInitDialog ();
Afx_msg void OnSysCommand (UINT nID, LPARAM LPARAM);
Afx_msg void OnPaint ();
Afx_msg HCURSOR OnQueryDragIcon ();
DECLARE_MESSAGE_MAP ()
};




//linkToLinkDlg. CPP: implementation file
//

# include "PCH. H"
# include "framework. H"
# include "linkToLink. H"
# include "linkToLinkDlg. H"
# include "afxdialogex. H"
#include
#include


# ifdef _DEBUG
# define new DEBUG_NEW
# endif


# define BKCOLOK RGB (0, 0)
# define FRONTW 41
# define FRONTH 51
# define BKWIDTH 46
# define BKHEIGHT 56
# define ROWCOUNT 7
# define COLCOUNT 12

# define BLANK_STATE - 1

//the width of the grid height
//line number column number
//state - blank

//for application "about" menu item CAboutDlg dialog

The class CAboutDlg: public CDialogEx
{
Public:
CAboutDlg ();

//data dialog
# ifdef AFX_DESIGN_TIME
Enum {IDD=IDD_ABOUTBOX};
# endif

Protected:
Virtual void DoDataExchange (CDataExchange * symbol;//support DDX/DDV

//implementation
Protected:
DECLARE_MESSAGE_MAP ()
};

CAboutDlg: : CAboutDlg () : CDialogEx (IDD_ABOUTBOX)
{
}

Void CAboutDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialogEx: : DoDataExchange (symbol);
}

BEGIN_MESSAGE_MAP (CAboutDlg CDialogEx)
END_MESSAGE_MAP ()



ClinkToLinkDlg: : ClinkToLinkDlg (CWnd *=nullptr pParent/* */)
: CDialogEx (IDD_LINKTOLINK_DIALOG, pParent)
{
M_hIcon=AfxGetApp () - & gt; LoadIcon (IDR_MAINFRAME);
M_nX1=BLANK_STATE;
M_nY1=BLANK_STATE;

//the number of rows
M_nRow=ROWCOUNT;
M_nCol=COLCOUNT;


M_map=new int [m_nRow * m_nCol];
}

ClinkToLinkDlg: : ~ ClinkToLinkDlg ()
{
The delete [] m_map;
}

Void ClinkToLinkDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialogEx: : DoDataExchange (symbol);
}

BEGIN_MESSAGE_MAP (ClinkToLinkDlg CDialogEx)
ON_WM_SYSCOMMAND ()
ON_WM_PAINT ()
ON_WM_QUERYDRAGICON ()
END_MESSAGE_MAP ()


//ClinkToLinkDlg message handler

BOOL ClinkToLinkDlg: : OnInitDialog ()
{
CDialogEx: : OnInitDialog ();

//will "about... "Menu item added to the system menu,

//IDM_ABOUTBOX must be in the system command range,
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);

CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=nullptr)
{
BOOL bNameValid;
Cstrings strAboutMenu;
BNameValid=strAboutMenu. LoadString (IDS_ABOUTBOX);
ASSERT (bNameValid);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}

//set this dialog ICONS, when the application is the main window is not a dialog, the framework will automatically
//do this
SetIcon (m_hIcon, TRUE);//set the large icon
SetIcon (m_hIcon, FALSE);//set the small icon
The CDC * pWinDC=GetDC ();
//3 d
M_mem3DBkDC. CreateCompatibleDC (pWinDC);
M_mem3DBkBmp. LoadBitmap (IDB_BITMAP2);
M_mem3DBkDC. SelectObject (& amp; M_mem3DBkBmp);

//animal pattern memory bitmap
M_memAnimalDC. CreateCompatibleDC (pWinDC);
M_memAnimalBmp. LoadBitmap (IDB_BITMAP1);
M_memAnimalDC. SelectObject (& amp; M_memAnimalBmp);

//the whole game area memory bitmap
M_MemDC. CreateCompatibleDC (pWinDC);
M_memBitmap. CreateCompatibleBitmap (pWinDC,
M_nCol * FRONTW + 5,
M_nRow * FRONTH + 5);
M_MemDC. SelectObject (& amp; M_memBitmap);

//HWND HWND=: : AfxGetMainWnd () - & gt; M_hWnd,
: : SetWindowPos (m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE);

StartNewGame ();

//animals
//the whole game area
Return TRUE;//unless set focus to the control, return TRUE
}
Void ClinkToLinkDlg: : StartNewGame ()
{
For (int iNum=0; INum & lt; (m_nRow * m_nCol); INum++)
{
M_map [iNum]=BLANK_STATE;
}
srand((unsigned int)time(NULL));
//generated random map
//put all matched pairs of animal species in a temporary map
CDWordArray tmpMap;
for (int i=0; I & lt; (m_nRow * m_nCol)/4; I++)
{
For (int j=0; J & lt; 4. nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related