We can use this as the last argument to CreateWindow and get a pointer to the app object in the WndProc like this:
if(message == WM_CREATE)
{
CREATESTRUCT* cs = (CREATESTRUCT*)lParam;
pApp = (DemoApp*)cs->lpCreateParams;
return 0;
}
What is the best way to access this pointer in a Dialog Message Proc? Is the solution to make a global pointer?
You get additional initialization data with
WM_INITDIALOG, see WM_INITDIALOG message :That is, you can pass
lParamas an argument withCreateDialogParamand the dialog proc will receive it withWM_INITDIALOGmessage.