I’m creating modeless 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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One way of doing it is to use SetWindowLongPtr():
This will set the USERDATA field on the parent hwnd to be the address of the parent class. Then in your
WM_INITDIALOGhandler, callGetWindowLongPtr()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_INITDIALOGhandler you’ll get the value you pass in thedwInitParamfield, which would be the pointer to your parent class.