Sign in to follow this  
cpp forever

Override method call

Recommended Posts

One more problem I have. I was developing Dialog class. Here is the main part of it:
class Dialog : public _Window {
protected:

  /**
   *
   */
  static INT_PTR CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    static Dialog* next_wnd;
    if(NULL == hwnd) {
      next_wnd = (Dialog *)lParam;
      return 0;
    }
    
    if(next_wnd) {
      SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)next_wnd);
      next_wnd = NULL;
    }
    
    
    Dialog* dialog = (Dialog *)GetWindowLongPtr(hwnd, GWL_USERDATA);
    
    if(!dialog) {
      return FALSE;
    }
    
    return dialog->DlgProc(msg, wParam, lParam);
  }
  
  /**
   *
   */
  virtual INT_PTR CALLBACK DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) {

    switch(msg) {
      case WM_INITDIALOG:
        //this->hWnd = 
        MessageBox(0,0,TEXT("base"),0);
        break;
    }

    return FALSE;
  }



And ConfDialog class (extends Dialog class):
class ConfDialog : public rr::Dialog {
protected:
  INT_PTR CALLBACK DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) {

    switch(msg) {
      case WM_INITDIALOG:
        //this->hWnd = 
        MessageBox(0,0,TEXT("1"),0);
        break;
    }
 
    return FALSE;
  }

The problem is that I don't know how to execute ConfDialog's DlgProc method from static INT_PTR CALLBACK DlgProc. Only Dialog's DlgProc method is executed. Changing lines (etc.) in static DlgProc to
    ConfDialog* dialog = (ConfDialog *)GetWindowLongPtr(hwnd, GWL_USERDATA);


might help, but that's not what is needed (not automatic).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this