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:
HRESULT AppObject::CreateDeviceIndependentResources(){
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,&m_pDirect2dFactory);
return hr;
}
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:
m_hwnd = CreateWindowEx(0, ...
and through the creation of the child windows:
m_hwndRenderView = CreateWindowEx(0,
L"AppChildWindow",
L"ChildWinName", WS_CHILD | WS_BORDER | WS_VISIBLE,
...
However when the code creates the Buttons:
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);
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.
Is this a know issue?