Advertisement

04.10.2008 at 04:26AM PDT, ID: 23311228
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Visual C++, MFC

Asked by larry84 in Microsoft Visual C++.Net, Windows MFC Programming, Microsoft Visual Basic.Net

Tags: ,

I am programming a game on a SDI. The display consists of three rectangles, a small rectangle in a larger rectangle within a larger rectangle. These rectangles are connected by 4 lines, 2 vertical, 2 horizintal, similar to a cross being placed on the rectangles except the cross doesn't show inside the inner rectangle. On each rectangle I can place either an x or an o at 8 different positions, on all the corners and half way between the corners. The object of the game is that there are two players, each places a piece on the display in alternate goes. Each player gets 6 pieces, if a player gets 3 of his pieces in a row he can remove one of the components pieces.

The problem I have is that I can display all 12 pieces but after all 12 pieces are placed I need to move pieces already placed.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
// E4gameView.cpp : implementation of the CE4gameView class
//
 
#include "stdafx.h"
#include "E4game.h"
 
#include "E4gameDoc.h"
#include "E4gameView.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView
 
IMPLEMENT_DYNCREATE(CE4gameView, CView)
 
BEGIN_MESSAGE_MAP(CE4gameView, CView)
	//{{AFX_MSG_MAP(CE4gameView)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView construction/destruction
 
CE4gameView::CE4gameView()
{
	// TODO: add construction code here
 
	
    for (int i=0; i<7; i++) {
	for (int j=0; j<7; j++) {
	int x=(i*70)+10;
	int y=-(j*70)-10;
	m_rect[i][j].SetRect(x,y,x +60, y - 60);
	m_rect[i][j].NormalizeRect();
	}
	}
}
 
CE4gameView::~CE4gameView()
{
}
 
BOOL CE4gameView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
 
	return CView::PreCreateWindow(cs);
}
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView drawing
 
void CE4gameView::OnDraw(CDC* pDC)
{
	CE4gameDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	pDC->SetMapMode (MM_LOENGLISH);
	//
	CRect rect;
	//
	// TODO: add draw code for native data here
	//
    CPen pen (PS_SOLID,5,RGB(0,0,255));
	CPen* pOldPen = pDC->SelectObject (&pen);
 
	pDC->MoveTo (30,-30);
	pDC->LineTo (30,-460);
    pDC->LineTo (460,-460);     //Big rect
    pDC->LineTo (460,-30);
    pDC->LineTo (30,-30);
 
    pDC->MoveTo (110,-110);
	pDC->LineTo (110,-390);
    pDC->LineTo (390,-390);    //Middle rect
    pDC->LineTo (390,-110);
    pDC->LineTo (110,-110);
 
    pDC->MoveTo (180,-180);
	pDC->LineTo (180,-320);
    pDC->LineTo (320,-320);     //Small rect
    pDC->LineTo (320,-180);
    pDC->LineTo (180,-180);
 
    pDC->MoveTo (30,-250);
	pDC->LineTo (180,-250);
 
    pDC->MoveTo (250,-30);
	pDC->LineTo (250,-180);
 
    pDC->MoveTo (320,-250);
	pDC->LineTo (460,-250);
 
    pDC->MoveTo (250,-320);
	pDC->LineTo (250,-460);
 
 
 
 
 
	pDC->SelectObject (pOldPen);
}
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView printing
 
BOOL CE4gameView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}
 
void CE4gameView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}
 
void CE4gameView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView diagnostics
 
#ifdef _DEBUG
void CE4gameView::AssertValid() const
{
	CView::AssertValid();
}
 
void CE4gameView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
 
CE4gameDoc* CE4gameView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CE4gameDoc)));
	return (CE4gameDoc*)m_pDocument;
}
#endif //_DEBUG
 
/////////////////////////////////////////////////////////////////////////////
// CE4gameView message handlers
 
void CE4gameView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
    //
    //
	CE4gameDoc*pDoc=GetDocument();
	//
	CClientDC dc (this);
	dc.SetMapMode (MM_LOENGLISH);
	dc.DPtoLP (&point);
	//
	//
	BOOL bQuit = FALSE;
	for (int i=0; i<7 && !bQuit; i++){
	for (int j=0; j<7 && !bQuit; j++){
	if (m_rect[i][j].PtInRect (point)){
    if(pDoc->GetSquare(i,j) ==0) {
    if (pDoc->Isitp1Turn()) {
						pDoc->Addpiece1 (i,j);
						Drawp1 (&dc, &m_rect[i][j]);
					}
					else{
						pDoc->Addpiece2 (i,j);
						Drawp2 (&dc, &m_rect[i][j]);
				}
				}
				bQuit = TRUE;
				
			}
		}
	}
 
	
	CView::OnLButtonDown(nFlags, point);
}
 
void CE4gameView::Drawp1(CDC *pDC, CRect *pRect)
{
    CE4gameDoc* pDoc = GetDocument();
    //
	//make a local copy of the rectangle and shrink it.
	//
	CRect rect;
	rect.CopyRect (pRect);
	rect.DeflateRect (1,1);
	//
	//create a red pen and use it to draw an x.
	//
	CPen pen (PS_SOLID,4,RGB(255,0,0));
	CPen* pOldPen = pDC->SelectObject (&pen);
	pDC->MoveTo (rect.left, rect.top);
	pDC->LineTo (rect.right, rect.bottom);
	pDC->MoveTo (rect.left, rect.bottom);
	pDC->LineTo (rect.right, rect.top);
	pDC->SelectObject (pOldPen);
 
	
 
    
}
 
void CE4gameView::Drawp2(CDC *pDC, CRect *pRect)
{
    CE4gameDoc* pDoc = GetDocument();
    //
	//make a local copy of the rectangle and shrink it
	//
    CRect rect;
	rect.CopyRect (pRect);
	rect.DeflateRect (1,1);
	//
	//Create a blue pen and use it to draw an O.
	//
	CPen pen (PS_SOLID, 4,RGB (0,255,0));
	CPen* pOldPen = pDC->SelectObject (&pen);
	pDC->SelectStockObject (NULL_BRUSH);
	pDC->Ellipse (rect);
	pDC->SelectObject (pOldPen);
 
    int count= pDoc->Getcount();
 
    if (count >=12){
    AfxMessageBox ("Move Piece");
    pDoc->OnNewDocument();
	
	}
 
}
[+][-]04.10.2008 at 04:28AM PDT, ID: 21323530

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 05:07AM PDT, ID: 21323766

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 05:12AM PDT, ID: 21323808

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 05:24AM PDT, ID: 21323909

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 07:46AM PDT, ID: 21325387

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.10.2008 at 08:27AM PDT, ID: 21325856

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C++.Net, Windows MFC Programming, Microsoft Visual Basic.Net
Tags: Visual C++, MFC
Sign Up Now!
Solution Provided By: alb66
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.07.2008 at 07:24AM PDT, ID: 21735614

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:42AM PDT, ID: 21735719

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2008 at 08:19PM PDT, ID: 21775679

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080924-EE-VQP-39 / EE_QW_2_20070628