title: Properly overriding WndProc
body: <p>One day ago I had started to rewrite one of my old components and I decided to improve its readability.
  My component is a typical <code>TWinControl</code> that has overridden <code>WndProc</code> to handle a lot of messages of my own. There are so many code for each message and it became a problem for me to read code.<br>
  So, looking for a solution to improve code inside <code>WndProc</code>, I have organized these large pieces of code in procedures that called each time when appropriate message has delivered in <code>WndProc</code>. That's how it looks now:  </p>
  
  <pre><code>procedure TMyControl.WndProc(var Message: TMessage);
  begin
    case Message.Msg of        
      WM_WINDOWPOSCHANGED: 
        WMWINDOWPOSCHANGED(Message);
      WM_DESTROY: 
        WMDESTROY(Message);
      WM_STYLECHANGED: 
        WMSTYLECHANGED(Message);
      //  lots of the same procedures for Windows messages
      //  ...
      MM_FOLDER_CHANGED: 
        MMFOLDERCHANGED(Message);
      MM_DIRECTORY_CHANGED: 
        MMDIRECTORYCHANGED(Message);
      //  lots of the same procedures for my own messages
      //  ...
    else
      Inherited WndProc(Message);
    end;
  end;
  </code></pre>
  
  <p>Unfortunately <code>Inherited</code> word in these procedures doesn't work anymore!  </p>
  
  <p><strong>Important note:</strong> in some of WM_XXX messages I didn't call <code>Inherited</code> to perform my own handling of such message, so code shown below will break down my efforts to implement some features.</p>
  
  <pre><code>procedure TMyControl.WndProc(var Message: TMessage);
  begin
    Inherited WndProc(Message);
    case Message.Msg of        
      WM_WINDOWPOSCHANGED: 
        WMWINDOWPOSCHANGED(Message);
      //  further messages
      //  ...
    end;
  end;
  </code></pre>
  
  <p>I also want to avoid inserting <code>Inherited</code> after each message-ID as shown below, because it looks awful and I think there is exists more elegant way to override <code>WndProc</code>.  </p>
  
  <pre><code>procedure TMyControl.WndProc(var Message: TMessage);
  begin      
    case Message.Msg of        
      WM_WINDOWPOSCHANGED: 
      begin
        Inherited WndProc(Message);
        WMWINDOWPOSCHANGED(Message);
      end;
      //  further messages
      //  ...
    end;
  end;
  </code></pre>
  
  <p>So my question is:<br>
  <em>how to properly override <code>WndProc</code> to have an ability to use code grouped in procedures and to be able to call for original window procedure only for some messages?</em></p>