No posts yet. Check back soon!
The dialog manager doesn’t remember the resource ID, but that doesn’t stop you from leaving your own breadcrumbs
03:00 PM · Dec 02, 2026
Some time ago, I noted that there is no way to recover the dialog resource ID that produced a dialog. I meant that in the sense that the dialog manager has no way of providing that information becaues it doesn’t remember it.
But that doesn’t mean that you can’t remember it.
For example, you could pass the dialog resource ID as a dialog creation parameter and have the dialog procedure’s WM_INITDIALOG save it as a window property.
DialogBoxParam(hinst, MAKEINTRESOURCE(IDD_MYDIALOG), hwndParent,
DlgProc, IDD_MYDIALOG);
// in the dialog procedure
case WM_INITDIALOG:
SetProp(hdlg, TEXT("DialogTemplateId"), (HANDLE)lParam);
⟦ ... other initialization ... ⟧
You could even encapsulate the special WM_INITDIALOG handling in a custom dialog class.
If you are already using the dialog creation parameter, you can have it be a pointer to a structure with two members, one being whatever you were using original dialog creation parameter for, and the other being the dialog template ID.
If you don’t control the code that calls DialogBox, you can put something in the dialog template that does become part of the resulting dialog.
For example, you could define a custom control called "Dialog Metadata" and add that control to the dialog template as a 0×0 hidden window, with the control text set to whatever information you want to remember.¹
CONTROL "⟦anything you want goes here⟧", -1,
"Dialog Metadata", 0, 0, 0, 0, NOT WS_VISIBLE
The custom control can parse its control text and call SetProp. Or it could just do nothing, and when you want to recover the original template ID, you can do a FindWindowEx for your "Dialog Metadata" window and ask for its window text and parse it.
¹ Or if you want to get fancy, put the template ID in the control data.
The post The dialog manager doesn’t remember the resource ID, but that doesn’t stop you from leaving your own breadcrumbs appeared first on The Old New Thing.