开发者

Modeless Child Dialog

开发者 https://www.devze.com 2023-01-08 08:06 出处:网络
I\'m creating mo开发者_如何学Cdeless child dialogs from a parent dialog class and i want to share the class data of its parent window with all child dialog classes I\'ll be creating. how would i go do

I'm creating mo开发者_如何学Cdeless child dialogs from a parent dialog class and i want to share the class data of its parent window with all child dialog classes I'll be creating. how would i go do that?


One way of doing it is to use SetWindowLongPtr():

SetWindowLongPtr(hwndParent, GWLP_USERDATA, (LONG_PTR)&parent_class);

This will set the USERDATA field on the parent hwnd to be the address of the parent class. Then in your WM_INITDIALOG handler, call GetWindowLongPtr() on your parent HWND and cast it back to the correct pointer type.

A better way to do it is to use CreateDialogParam() and in your WM_INITDIALOG handler you'll get the value you pass in the dwInitParam field, which would be the pointer to your parent class.

0

精彩评论

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