开发者

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, or DialogBoxParam function used to create the dialog box. For property sheets, this parameter is a pointer to the PROPSHEETPAGE 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜