At some point, I have this
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg==WM_CREATE)
{
LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam;
D2DResources* pD2DResources = (D2DResources*)pcs->lpCreateParams;
::SetWindowLongPtrW(
hWnd,
GWLP_USERDATA,
PtrToUlong(pD2DResources)
);
}
else
{
D2DResources* pD2DResources = reinterpret_cast<D2DResources*>(static_cast<LONG_PTR>(
::GetWindowLongPtrW(
hWnd,
GWLP_USERDATA
)));
switch(msg)
{
case WM_PAINT:
{
pD2DResources->OnRender();
ValidateRect(hWnd, NULL);
}
break;
case WM_SIZE:
{
UINT width = LOWORD(lParam);
UINT height = HIWORD(lParam);
pD2DResources->OnResize(width, height);
}
break;
So my WinProc has access to a previously created D2DResources. Now I want it to have access to another previously created object. How do I do that? I mean, can it have access to more than one previously created object? If so, how?
Edit: Raymond Chen said: "Pass a pointer to a structure as the lpCreateParams. You can put anything you want in the structure." How do I do that? Can anyone give me an exemple?