Jump to content
  • Advertisement
Sign in to follow this  
cpp forever

Override method call

This topic is 4470 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!