Click here to Skip to main content
15,902,032 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Socket question: How to send different datatypes in a byte array ? Pin
FreeCastle22-Dec-06 9:42
FreeCastle22-Dec-06 9:42 
QuestionProblem displaying characters above the normal ASCII Range Pin
TheDelChop20-Dec-06 9:57
TheDelChop20-Dec-06 9:57 
AnswerRe: Problem displaying characters above the normal ASCII Range Pin
PJ Arends20-Dec-06 10:42
professionalPJ Arends20-Dec-06 10:42 
GeneralRe: Problem displaying characters above the normal ASCII Range Pin
TheDelChop20-Dec-06 10:54
TheDelChop20-Dec-06 10:54 
Questionps2 adapter interface Pin
ahmad al-omar20-Dec-06 7:37
ahmad al-omar20-Dec-06 7:37 
QuestionCListCtrl - FindItem - finding sub-items Pin
Like2Byte20-Dec-06 6:56
Like2Byte20-Dec-06 6:56 
AnswerRe: CListCtrl - FindItem - finding sub-items Pin
James R. Twine20-Dec-06 7:28
James R. Twine20-Dec-06 7:28 
QuestionProgram is all hosed up...need OOP/MFC help Pin
CoffeeAddict1920-Dec-06 6:42
CoffeeAddict1920-Dec-06 6:42 
I'd really appreciate it if someone could look at these header files and give me some idea how to fix them. Basically what I have is a tic-tac-toe program in MFC. I have a main window, which is class CGameWin (inherits from CFrameWnd) and a dialog box class called CGameKeyBindingDialog (inherits from CDialog). Previously I did almost everything in CGameWin, and everything worked out fine. Then CGameWin got bloated with functions that were related to game mechanics rather than graphics or window handling, so I decided to create the class GameOperations. It does everything for the game not related to graphics or window handling. That's when everything got hosed up. Here are the class related errors I'm getting:

e:\Homework\CS\CS2\Game\game_interface.h(14): error C2011: 'CGameKeyBindingDialog' : 'class' type redefinition
e:\Homework\CS\CS2\Game\game_interface.h(29): error C2011: 'CGameWin' : 'class' type redefinition
e:\Homework\Cs\Cs2\Game\game_operations.cpp(50): error C2065: 'CGameWinPtr' : undeclared identifier
e:\Homework\Cs\Cs2\Game\game_interface.cpp(16): error C2065: 'Operations' : undeclared identifier
e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP messageMap 1' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP CGameKeyBindingDialog::messageMap' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP_ENTRY _messageEntries 0[]' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP_ENTRY CGameKeyBindingDialog::_messageEntries[]' : redefinition

game_interface.h:

#ifndef GAME_INTERFACE_H
#define GAME_INTEFRACE_H

#include <afxwin.h>
#include "game_operations.h"
#include <defenitions.h>

using namespace std;

class CGameWin;

class CGameKeyBindingDialog : public CDialog
{
public:
CGameKeyBindingDialog(char* lpszName);
BOOL OnInitDialog();
CGameWin* getMainWnd();
void setMainWnd(CGameWin* mp);
void InitAll();
afx_msg void OnExitDialog();
private:
CGameWin* m_pMainWnd; //pointer to main window

DECLARE_MESSAGE_MAP()
};

class CGameWin : public CFrameWnd
{
public:
CGameWin();
~CGameWin();
void PopMessageBox(LPCSTR Message, LPCSTR Title, UINT Style);
afx_msg void OnPaint();
//input handling
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//file menu "File"
afx_msg void OnNewGame();
afx_msg void OnExit();
//graphics
void RedrawScreen(CDC* Surface, int MouseOverPosition, bool MouseOver);
void DrawXOs();
void DrawMouseOvers(int Position, MouseOverType MouseOver);
void DrawBitmaps();
void RefreshOffSet();
//game stuff
int ConfirmExit();
PlayerType GetPlayerSide();

private:
//classes
CGameKeyBindingDialog CGameKeyBindingDialog;
GameOperations Operations;
//graphics
CDC grid_DC; //grid memory device context
CDC xo_DC; //xos memory device context
CDC buffer_DC; //buffer device context
CBitmap CBitGrid;
CBitmap CBitXO;
CBitmap CBitBackBuffer;
int OffSetX;
int OffSetY;
void DrawMonoLine(CDC* Surface, int srcX, int srcY, int destX, int destY);
void DrawCircle(CDC* Surface, int srcX, int srcY, int Diameter);
void DrawSquare(CDC* Surface, int srcX, int srcY, int Side);
//brushes and pens
void InitBrushPen();
void DeleteBrushPen();
CPen BlackPen;
CPen XGreenPen;
CPen OBluePen;
CPen RedErrorPen;
CPen DashBoxGreenPen;
CPen DashBoxBluePen;

DECLARE_MESSAGE_MAP()
};

#endif

game_interface.cpp, CGameWin constructor:

CGameWin::CGameWin() : CGameKeyBindingDialog("CKeyboardDialog") : GameOperations("Operations")
{
Create(NULL, "Tic-Tac-Toe", WS_OVERLAPPEDWINDOW,
rectDefault, NULL, "Game");
CGameKeyBindingDialog.setMainWnd(this);
Operations.SetPtrToMainWindow(this);
OffSetX, OffSetY = 0;
InitGrid();
CBitGrid.CreateBitmap(150, 150, 1, 32, NULL);
grid_DC.CreateCompatibleDC(NULL);
grid_DC.SelectObject(CBitGrid);
buffer_DC.CreateCompatibleDC(&grid_DC);
xo_DC.CreateCompatibleDC(&grid_DC);
CBitXO.CreateCompatibleBitmap(&grid_DC, 150, 100);
CBitBackBuffer.CreateCompatibleBitmap(&grid_DC, 400, 400);
InitBrushPen();
DrawBitmaps();
Operations.SetPlayerSide(GetPlayerSide());
}

game_operations.h:

#ifndef GAME_OPERATIONS_H
#define GAME_OPERATIONS_H

#include <defenitions.h>
#include "game_interface.h"

using namespace std;

class GameOperations
{
public:
GameOperations();
~GameOperations();
void InitGrid();
bool ConfirmLegalMove(GridStateType NewState, int GridX, int GridY);
void PlaceXorO(CPoint MousePosition, PlayerType CurrentSide);
void SetPlayerSide(PlayerType NewSide);
PlayerType ReturnPlayerSide();
void SetPtrToMainWindow(CGameWin* NewPtr);
protected:
GridSquareType Grid[3][3];
private:
CGameWin* PtrToMainWindow;
PlayerType PlayerSide;
};

#endif

I know I'm asking a lot, but I'd really appreciate any help.
AnswerRe: Program is all hosed up...need OOP/MFC help Pin
Chris Losinger20-Dec-06 7:47
professionalChris Losinger20-Dec-06 7:47 
AnswerRe: Program is all hosed up...need OOP/MFC help Pin
Mark Salsbery20-Dec-06 7:51
Mark Salsbery20-Dec-06 7:51 
GeneralRe: Program is all hosed up...need OOP/MFC help Pin
CoffeeAddict1920-Dec-06 9:24
CoffeeAddict1920-Dec-06 9:24 
QuestionProblem with D3DFont Aliasing [modified] Pin
Dustin Henry20-Dec-06 6:37
Dustin Henry20-Dec-06 6:37 
QuestionShell Programming Pin
Fwzklmn20-Dec-06 5:37
Fwzklmn20-Dec-06 5:37 
AnswerRe: Shell Programming Pin
Robert Kuster20-Dec-06 5:46
Robert Kuster20-Dec-06 5:46 
AnswerRe: Shell Programming Pin
James R. Twine20-Dec-06 6:25
James R. Twine20-Dec-06 6:25 
QuestionMFC CEdit scrollbar question Pin
FredrickNorge20-Dec-06 4:57
FredrickNorge20-Dec-06 4:57 
AnswerRe: MFC CEdit scrollbar question Pin
Robert Kuster20-Dec-06 5:37
Robert Kuster20-Dec-06 5:37 
GeneralRe: MFC CEdit scrollbar question Pin
FredrickNorge20-Dec-06 5:57
FredrickNorge20-Dec-06 5:57 
QuestionTo show an image from one directory Pin
mikobi20-Dec-06 4:52
mikobi20-Dec-06 4:52 
AnswerRe: To show an image from one directory Pin
mikobi20-Dec-06 5:41
mikobi20-Dec-06 5:41 
AnswerRe: To show an image from one directory Pin
Hamid_RT21-Dec-06 1:42
Hamid_RT21-Dec-06 1:42 
QuestionURI strings Pin
viliam20-Dec-06 3:53
viliam20-Dec-06 3:53 
AnswerRe: URI strings Pin
James R. Twine20-Dec-06 4:07
James R. Twine20-Dec-06 4:07 
QuestionHow to register DLL in APP path Pin
sp_ranjan20-Dec-06 3:52
sp_ranjan20-Dec-06 3:52 
AnswerRe: How to register DLL in APP path Pin
James R. Twine20-Dec-06 4:05
James R. Twine20-Dec-06 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.