Hello everybody.

My project is composed by some dialogs of base type CMyDlg which receives characters and manages them by a function "OnCharReceived" called by the environment upon char generation/reception. Each derived dialog can perform different actions on Char reception:

Code:
class CMyDlg:public CDialog
{
public:
  CMyDlg():CDialog(){};
  BOOL OnCharReceived( CHAR c){ return (*m_pcurrentCharHandler)( c );  }

protected:
  virtual BOOL privCharHandler( CHAR c );
  BOOL (CMyDlg::*m_pcurrCharHandler)(CHAR c );
  
}

class CMyDlgOne:public CMyDlg
{
public:
  CMyDlgOne():CMyDlg(){}

private:
  BOOL privCharHandler( CHAR c );  //overridden method
  BOOL privCharHandler_2( CHAR c); //new method
}
What I want to do is to programmatically set "m_pcurrCharHandler" to change the "CharHandler" function from a method inside the CMyDlgOne class. Let's say that, if I receive 'Z' I want all the next chars to be handled by privCharHandler_2:
Code:
BOOL CMyDlgOne::privCharHandler( CHAR c)
{
  if( c == 'z' )
    m_pcurrCharHandler = privCharHandler_2;

  return TRUE;
}
Also, if a derived class does not override "privCharHandler()", I want that it can use the function of the base class:
Code:
class CMyDlgTwo: public CMyDlg
{
public:
  //some methods, not important

private:
  BOOL privCharHandler_3( CHAR c); //new method
}


BOOL CMyDlgTwo::OnCharReceived( CHAR c)
{
  if( c == 'z' )
    m_pcurrCharHandler = privCharHandler_3;     //new method
  else
    m_pcurrCharHandler = privCharHandler;	//base class method

  return (*m_pcurrCharHandler)(c);
}
Is there a way todo this? If yes, how do you write correctly the code to use the method pointer? If not, is there another way to do a "prigrammatically" change of working function? I'm thinking about state variables, and then "switch()" on their value to do different things, but I'd like something more flexible I think.

Thank you for any hint and correction.

BrownB