title: Preprocessor Macro Automatically Generate Window Msg Loop
body: <p>I have a constructor for a window in my project setup such that it looks like this. There are many windows in my project and I'm constantly adding or removing things.</p>
  
  <pre><code>LRESULT CPicture::Msg(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  {
      switch(uMsg)
      { 
          HANDLE_MSG(hWnd, WM_CREATE, OnCreate);
          HANDLE_MSG(hWnd, WM_PAINT, OnPaint);
          HANDLE_MSG(hWnd, WM_SIZE, OnSize);
          HANDLE_MSG(hWnd, WM_CLOSE, OnDestroy);
  
          default:
              return (DefWindowProc(hWnd, uMsg, wParam, lParam));
      }
  }
  </code></pre>
  
  <p>Here is an example of all the valid events;</p>
  
  <pre><code>// Csx / Dsx
  virtual BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct) {return FALSE;};
  virtual void OnDestroy(HWND hWnd){};
  
  // Painting
  virtual void OnPaint(HWND hWnd){};
  virtual BOOL OnEraseBkgnd(HWND hWnd, HDC hDC) {return FALSE;};
  
  // Movement / Sizing
  virtual void OnMove(HWND hWnd, int x, int y) {};
  virtual void OnSize(HWND hWnd, UINT state, int nWidth, int nHeight){};
  virtual void OnGetMinMaxInfo(HWND hWnd, LPMINMAXINFO lpMinMaxInfo){};
  
  // Focus
  virtual void OnSetFocus(HWND hWnd, HWND hWndOldFocus){};
  virtual void OnKillFocus(HWND hWnd, HWND hWndNewFocus){};
  </code></pre>
  
  <p>... and lots more. Is it possible using preprocessor macros to detect when one of these functions is overridden in a child class and automatically add a handler for it to the message loop?</p>
  
  <p>I was told by someone that It was a really bad idea for my <code>Msg()</code> to handle every message even if it wasn't defined, so I'm looking for an easy alternative that isn't user-heavy on constantly adding/removing event definitions.</p>