Hi guys,
How do I explain my questions under 50 words or less?!
I have a class called WinApp and a class called Game. Inside both WinApp and Game classes I have a message pump. The Game class uses WinApp as a "Has-A". Problem: I would like to be able to have the Game class handle the messages (keyboard input, mouse moves, etc. ) coming in from the WinApp message pump. Once the Game class gets the messages it will forward those messages to another class (Input class). Some code for you to ponder on:
class WinApp
{
public:
static LRESULT CALLBACK MsgProc(.....);
... other code.
};
class Game
{
private:
WinApp myApp;
pubilc:
static LRESULT CALLBACK MessagePump(.....);
void MouseEvent( int iState, bool bBtndown ); // This will get passed to Input class from the msg pump
void IsKeyDown( char *pKey, bool bIsDown ); // This will get passed to Input class from the msg pump
void KeyEvent( int EvntCode, int KeyNum, const char pcKeyName ); // This will get passed to Input class from the msg pump
.... other code.
};
Whew.... okay now for the question. Anybody have an idea on a solution? I've tried a global pointer within the Game class ("extern Game *g_pGame;" is in the header file) and used:
LRESULT CALLBACK WinApp::MsgProc(...)
case WM_KEYDOWN:
{
g_pGame->MsgProc(....); // OPPS. WRONG!
g_pGame->MessagePump(.....); // Want to use Game msg pump. NOT WinApp msg pump. But I think people know what I'm trying to do
}
but this does not seem to be working. Does anyone see what I am missing or over looking?
Thank you.
S
(Edited: Fix code example)
How do I explain my questions under 50 words or less?!
I have a class called WinApp and a class called Game. Inside both WinApp and Game classes I have a message pump. The Game class uses WinApp as a "Has-A". Problem: I would like to be able to have the Game class handle the messages (keyboard input, mouse moves, etc. ) coming in from the WinApp message pump. Once the Game class gets the messages it will forward those messages to another class (Input class). Some code for you to ponder on:
class WinApp
{
public:
static LRESULT CALLBACK MsgProc(.....);
... other code.
};
class Game
{
private:
WinApp myApp;
pubilc:
static LRESULT CALLBACK MessagePump(.....);
void MouseEvent( int iState, bool bBtndown ); // This will get passed to Input class from the msg pump
void IsKeyDown( char *pKey, bool bIsDown ); // This will get passed to Input class from the msg pump
void KeyEvent( int EvntCode, int KeyNum, const char pcKeyName ); // This will get passed to Input class from the msg pump
.... other code.
};
Whew.... okay now for the question. Anybody have an idea on a solution? I've tried a global pointer within the Game class ("extern Game *g_pGame;" is in the header file) and used:
LRESULT CALLBACK WinApp::MsgProc(...)
case WM_KEYDOWN:
{
g_pGame->MsgProc(....); // OPPS. WRONG!
g_pGame->MessagePump(.....); // Want to use Game msg pump. NOT WinApp msg pump. But I think people know what I'm trying to do
}
but this does not seem to be working. Does anyone see what I am missing or over looking?
Thank you.
S
(Edited: Fix code example)
The post was edited 1 time, last by Sabrina ().