• Advertisement
Sign in to follow this  

Override method call

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement