What's the proper way to subclass a dialog so that its class name will change to a specified one, so it would be later found with FindWindow (from another process)?
class CMyDialog : public CDialogImpl<CMyDialog, CWindow> {
public:
enum { IDD = IDD_MAIN };
// error: CDialogImpl doesn't support GetWndClassInfo
DECLARE_WND_CLASS(L"unique class name")
};
After some additional search I found How to provide your own Window class name for an MFC dialog box. There is nothing MFC specific though.
In summary:
Add CLASS "your class name"
field to the dialog resource. It can be done from within the GUI: disable MFC Mode on the resource file properties, then Class Name property appears in the dialog properties.
Subclass the WC_DIALOG class as follows:
WNDCLASSEXW wc;
wc.cbSize = sizeof(WNDCLASSEX);
::GetClassInfoExW(0, WC_DIALOG, &wc);
wc.lpszClassName = "your window class";
wc.style &= ~CS_GLOBALCLASS;
::RegisterClassExW(&wc);
Extra reading: https://blogs.msdn.microsoft.com/oldnewthing/20100215-00/?p=14943/