title: Visual c++ WndProc override MySplitContainerControl::WndProc(m);
body: <p>Doing some testing ... on ownerdraw custom controls.</p>
  
  <p>this code compile, but crashes ... due to that 'm' is <code>&lt;undefined value&gt;</code></p>
  
  <p><code>MySplitContainerControl::WndProc(m);</code> /*with brakepoint, i can see a messages .... but remove the brake point will result in crash!</p>
  
  <p>i'm trying to override the windows look from the Splitcontainer.</p>
  
  <pre><code>protected: static int WM_PAINT = 0x000F;
  protected: virtual void WndProc(Message% m) override 
      {
      MySplitContainerControl::WndProc(m); 
      /*Form::WndProc(m);*/
      if (m.Msg == WM_PAINT)
          {
                  Graphics^ graphics = Graphics::FromHwnd(this-&gt;Handle);
                  PaintEventArgs^ pe = gcnew PaintEventArgs(graphics, Rectangle(0,0, this-&gt;Width, this-&gt;Height));
                  OnPaint(pe);
          }
  </code></pre>
  
  <p>To get an idea, what i'm doing here is the complete code:</p>
  
  <pre><code>#pragma once
  
  using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;
  
  
  namespace MySplitContainer {
  
      /// &lt;summary&gt;
      /// Summary for MySplitContainerControl
      /// &lt;/summary&gt;
      public ref class MySplitContainerControl : public System::Windows::Forms::SplitContainer
      {
      public:
          MySplitContainerControl(void)
          {
              InitializeComponent();
              //
              //TODO: Add the constructor code here
              //
          }
  
      protected:
          /// &lt;summary&gt;
          /// Clean up any resources being used.
          /// &lt;/summary&gt;
          ~MySplitContainerControl()
          {
              if (components)
              {
                  delete components;
              }
          }
  
      private:
          /// &lt;summary&gt;
          /// Required designer variable.
          /// &lt;/summary&gt;
          System::ComponentModel::Container^ components;
  
  #pragma region Windows Form Designer generated code
          /// &lt;summary&gt;
          /// Required method for Designer support - do not modify
          /// the contents of this method with the code editor.
          /// &lt;/summary&gt;
          void InitializeComponent(void)
          {
              this-&gt;AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
          }
  #pragma endregion
  
      protected: static int WM_PAINT = 0x000F;
      protected: virtual void WndProc(Message% m) override 
          {
          MySplitContainerControl::WndProc(m);
          /*Form::WndProc(m);*/
          if (m.Msg == WM_PAINT)
              {
                      Graphics^ graphics = Graphics::FromHwnd(this-&gt;Handle);
                      PaintEventArgs^ pe = gcnew PaintEventArgs(graphics, Rectangle(0,0, this-&gt;Width, this-&gt;Height));
                      OnPaint(pe);
              }
          }
  
      protected: virtual void OnPaint(PaintEventArgs ^e) override
          {
  
          }
  
      };
  }
  </code></pre>