Modeless Child Dialog
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.
精彩评论