Override method call

Started by
-1 comments, last by cpp forever 17 years, 11 months ago
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).
ai-blog.org: AI is discussed here.

This topic is closed to new replies.

Advertisement