I am working on a plug-in for Adobe Illustrator using hotdoor framework, so I don't really have any deep access to window creation\init process. That being said, I've been using openGL to render some graphics in my plug-in. I retrieved CWnd from a widget and used it to init openGL context, something like this:
CWnd *pWnd = frame.platformWidget();
HWND mHwnd = pWnd->GetSafeHwnd();
HDC mHdc = pWnd->GetDC()->m_hDC;
//set pixel format etc
HGLRC mHglrc = wglCreateContext(mHdc);
wglMakeCurrent(mHdc, mHglrc);
Then I just hooked my update\draw cycle to a timer. It worked fine. However after Win10 1709 update rendered graphics disappeared from my window. First thing I've checked the context and it appeared fine. Dumping the context to an image file after drawing resulted in correct image with size and content corresponding to what I've expected to see in viewport. So I could only assume that window lifecycle changed somehow after 1709 update but reading update notes did not give me any clue to where my graphics could get invalidated. Right now I'm not even sure in what direction I should investigate, so any suggestion is welcome.
Update: I've done some experimenting with this. I've tried to get a handler for windows native proc for the widget and tinker a little with it so that in case of WM_PAINT default winproc is used and in all other cases old handler is used.
std::map<HWND, LONG_PTR> oldHandlerMap;
typedef LRESULT (*WndProcType)(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProcTst (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_PAINT)
{
return DefWindowProc(hwnd, message, wParam, lParam) ;
}
WndProcType oldHandlerPtr = (WndProcType)oldHandlerMap[hwnd];
return CallWindowProc((WNDPROC)oldHandlerPtr, hwnd, message, wParam, lParam);
}
void RehookWinProc(const hdi::core::CustomWidget& parent)
{
CWnd *pWnd = parent.platformWidget();
HWND tmpHwnd = pWnd->GetSafeHwnd();
LONG_PTR oldHandler = GetClassLongPtr(tmpHwnd, GCLP_WNDPROC);
oldHandlerMap[tmpHwnd] = oldHandler;
SetWindowLongPtr(tmpHwnd, GWLP_WNDPROC, (LONG_PTR)WndProcTst);
}
Now I can see the graphics, however all the callbacks related to widget like mouse down, mouse up etc are gone. Still trying to figure this out.