( similar problem as "How to get WNDCLASS from HWND?",How to get WNDCLASS from HWND? in which WNDCLASSEX is wished to be modificated )
I have tried to set WNDCLASSEX::lpszClassName to be able to identify Window handles from MainFrames of our own MFC-Apps (to distinguish from existing Wnds which have the same PID) (to let them communicate via WM_COPY-DATA-Messages) it seems to work in
CMainFrame::PreCreateWindow(CREATESTRUCT &cs)
// m_hWnd is still NULL, so no dependant Wnds should exist but cs.lpszClass even contains (registered?!) className of the Mainframe-Window
{
if (cs.lpszClass!=NULL) { // when second call happens
WNDCLASSEX wce;
GetClassInfoEx(AfxGetInstanceHandle(),cs.lpszClass,&wce);
wce.lpszClassName="Test";
UnregisterClass(cs.lpszClass,AfxGetInstanceHandle());
RegisterClassEx(&wce);
GetClassInfoEx(AfxGetInstanceHandle(),cs.lpszClass,&wce); // wce.lpszClassName="Test" :-)
};
if(!CMDIFrameWndEx::PreCreateWindow(cs)) return FALSE;
}
but merely with that CMainFrame::LoadFrame returns FALSE and App doesn'r start ...
( In search procedure we'd like to get
// ... HWND hw ;
TCHAR className[256] ;
GetClassName(hw, className, 256);
WNDCLASSEX wce;
GetClassInfoEx(GetModuleHandle(nullptr), className, &wce);
// if (wce.lpszClassName=="Test") ... // Mainframe of own App
)
Martin