title: Button creation invalidating Direct2dFactory pointers Windows C++
body: <p>I am writing a windows App in MS Visual Studio 2017 and having a little trouble using a Direct 2D Factory object and Buttons.
  It appears that if I create the direct 2D Factory object first a.k.a.
  run:</p>
  
  <pre><code>HRESULT AppObject::CreateDeviceIndependentResources(){
         hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,&amp;m_pDirect2dFactory);
         return hr;
      }
  </code></pre>
  
  <p>The factory object is created correctly with a pointer stored in "m_pDirect2dFactory" as it should be. 
  This object pointer persist through the creation of the main window:</p>
  
  <pre><code>m_hwnd = CreateWindowEx(0, ...  
  </code></pre>
  
  <p>and through the creation of the child windows:</p>
  
  <pre><code>m_hwndRenderView = CreateWindowEx(0, 
                                     L"AppChildWindow", 
                                     L"ChildWinName", WS_CHILD | WS_BORDER | WS_VISIBLE, 
                                     ...   
  </code></pre>
  
  <p>However when the code creates the Buttons:</p>
  
  <pre><code>m_hwndButton = CreateWindow(L"BUTTON", 
                              TEXT("button name"),
                              WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                              m_buttonStart_pixX,
                              cur_button_pixY,
                              button_pix_width,
                              button_pix_height,
                              m_hwnd,
                              (HMENU)(int)(CORE_BUTTON_IDSTART+1),
                              (HINSTANCE)GetWindowLong(m_hwnd, GWL_HINSTANCE),
                              NULL);
  </code></pre>
  
  <p>The value of the pointer "m_pDirect2dFactory" changes to an apparently invalid value which causes an error when 
      m_pDirect2dFactory->Release() 
  is called.
  Or, in other words, the creation of the buttons tampers with the factory object created by D2D1CreateFactory.</p>
  
  <p>Is this a know issue?  </p>