I try to get rid of some Windows callbacks and variables in global scope. The Windows callbacks can be made class member methods (i.e. static), extracting the right instance and invoking the callback of that instance:
if (WM_NCCREATE == uMsg) {
const LONG_PTR replacement_value = (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, replacement_value);
return TRUE;
}
((DeviceEnumeration *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA))->SettingsDialogProc(hwndDlg, uMsg, wParam, lParam);
This works by passing "this" as the "lpParam" in "CreateWindow".
Is a similar approach possible for "DialogBox"?
↧