Getting app object pointer in Dialog Message Proc
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;
p开发者_如何学编程App = (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 :
lParam
Additional initialization data. This data is passed to the system as the lParam parameter in a call to the
CreateDialogIndirectParam
,CreateDialogParam
,DialogBoxIndirectParam
, orDialogBoxParam
function used to create the dialog box. For property sheets, this parameter is a pointer to thePROPSHEETPAGE
structure used to create the page. This parameter is zero if any other dialog box creation function is used.
That is, you can pass lParam
as an argument with CreateDialogParam
and the dialog proc will receive it with WM_INITDIALOG
message.
精彩评论