Click here to Skip to main content
15,921,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalvirtual function crash Pin
Steve Severance29-Apr-02 14:11
Steve Severance29-Apr-02 14:11 
GeneralRe: virtual function crash Pin
Tim Smith29-Apr-02 14:17
Tim Smith29-Apr-02 14:17 
GeneralRe: virtual function crash Pin
Steve Severance29-Apr-02 16:51
Steve Severance29-Apr-02 16:51 
GeneralRe: virtual function crash Pin
Nish Nishant29-Apr-02 14:20
sitebuilderNish Nishant29-Apr-02 14:20 
GeneralRe: virtual function crash Pin
Steve Severance29-Apr-02 16:51
Steve Severance29-Apr-02 16:51 
GeneralRe: virtual function crash Pin
Neville Franks30-Apr-02 2:11
Neville Franks30-Apr-02 2:11 
GeneralRe: virtual function crash Pin
30-Apr-02 7:30
suss30-Apr-02 7:30 
GeneralRe: virtual function crash Pin
Steve Severance30-Apr-02 19:27
Steve Severance30-Apr-02 19:27 
The error is runtime(Access Violation) not compile time.

Here is actual source.

Header

class CInputCommandMap
{
public:
	CInputCommandMap();
	~CInputCommandMap();

	void LoadCommandMap(char *file);
	virtual void ProcessInput(char *keys, DIMOUSESTATE2 *mouse) = 0;
	
	CInputCommand m_keyA;
	CInputCommand m_keyB;
	CInputCommand m_keyC;
        More Keys...
};

class CDefaultKeyMap : public CInputCommandMap
{
public:
	CDefaultKeyMap(){}
	~CDefaultKeyMap(){}

	void ProcessInput(char *keys, DIMOUSESTATE2 *mouse);
};


ProcessInput is overridden and contains the actual implentation.

LoadCommandMap is
void LoadCommandMap(CInputCommandMap *map){m_pCommandMap = map;}


I use it like this.
pDefaultCommandMap = new CDefaultKeyMap;
pDefaultCommandMap->LoadCommandMap("default.key");
pInput->LoadCommandMap(pDefaultCommandMap);

    Code...In an update function that is in the main input class

if(m_pCommandMap)
    m_pCommandMap->ProcessInput((char *)m_Keys,&m_MouseState);

Thanks once again for all you guys help.


Steve

Not all who wander are lost...
GeneralRe: virtual function crash Pin
Mike Nordell1-May-02 9:15
Mike Nordell1-May-02 9:15 
QuestionLayered child windows? Pin
Eugene Polonsky29-Apr-02 12:44
Eugene Polonsky29-Apr-02 12:44 
AnswerRe: Layered child windows? Pin
Mike Nordell29-Apr-02 13:08
Mike Nordell29-Apr-02 13:08 
GeneralRe: Layered child windows? Pin
Shog929-Apr-02 13:26
sitebuilderShog929-Apr-02 13:26 
AnswerRe: Layered child windows? Pin
Shog929-Apr-02 13:21
sitebuilderShog929-Apr-02 13:21 
Generaltwo dialogs Pin
tordyvel29-Apr-02 12:43
tordyvel29-Apr-02 12:43 
GeneralRe: two dialogs Pin
Shog929-Apr-02 13:36
sitebuilderShog929-Apr-02 13:36 
GeneralRe: two dialogs Pin
Nish Nishant29-Apr-02 14:12
sitebuilderNish Nishant29-Apr-02 14:12 
GeneralRe: two dialogs Pin
Shog929-Apr-02 15:15
sitebuilderShog929-Apr-02 15:15 
GeneralRe: two dialogs Pin
Nish Nishant29-Apr-02 15:20
sitebuilderNish Nishant29-Apr-02 15:20 
GeneralRe: two dialogs Pin
Shog929-Apr-02 15:01
sitebuilderShog929-Apr-02 15:01 
GeneralRe: two dialogs Pin
Nish Nishant29-Apr-02 15:20
sitebuilderNish Nishant29-Apr-02 15:20 
GeneralHidden dialog Pin
29-Apr-02 12:43
suss29-Apr-02 12:43 
GeneralRe: Hidden dialog Pin
Nish Nishant29-Apr-02 14:13
sitebuilderNish Nishant29-Apr-02 14:13 
GeneralRe: Hidden dialog Pin
Sameer Maggon29-Apr-02 19:21
Sameer Maggon29-Apr-02 19:21 
GeneralRe: Hidden dialog Pin
Gaurika Wijeratne29-Apr-02 20:05
Gaurika Wijeratne29-Apr-02 20:05 
GeneralI need help with file select. Pin
Strife Fox29-Apr-02 11:53
Strife Fox29-Apr-02 11:53 

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.