Assertion From SendNotifyMessage
-
I am doing Interprocess communication between a C console app and C++ Windows app The C console app is the parent process I have the Window handle (main window MainFrame) of the C++ child app I use SendNotifymessage to tell the child app that console app has data for it in shared storage The First time I do this all is well The Second time around I have created a modless dialog box with a Crichedit control it is at this time where I get a asseration from the SendNotifyMessage in the console C app The assetration is dlgcore.cpp at the parent GetSafeHWnd
lpDialogTemplate = (DLGTEMPLATE\*)GlobalLock(hTemplate); // setup for modal loop and creation m\_nModalResult = -1; m\_nFlags |= WF\_CONTINUEMODAL; // create modeless dialog AfxHookWindowCreate(this); hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, **pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG**
dwError = ::GetLastError();
#endif
}
CATCH_ALL(e)
{ -
I am doing Interprocess communication between a C console app and C++ Windows app The C console app is the parent process I have the Window handle (main window MainFrame) of the C++ child app I use SendNotifymessage to tell the child app that console app has data for it in shared storage The First time I do this all is well The Second time around I have created a modless dialog box with a Crichedit control it is at this time where I get a asseration from the SendNotifyMessage in the console C app The assetration is dlgcore.cpp at the parent GetSafeHWnd
lpDialogTemplate = (DLGTEMPLATE\*)GlobalLock(hTemplate); // setup for modal loop and creation m\_nModalResult = -1; m\_nFlags |= WF\_CONTINUEMODAL; // create modeless dialog AfxHookWindowCreate(this); hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, **pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG**
dwError = ::GetLastError();
#endif
}
CATCH_ALL(e)
{pParentWnd
is NULL or the window has not yet been created (it'sHWND
member is NULL). I can give no more help because you did not show the relevant code parts (the posted code seems to be MFC source). -
I am doing Interprocess communication between a C console app and C++ Windows app The C console app is the parent process I have the Window handle (main window MainFrame) of the C++ child app I use SendNotifymessage to tell the child app that console app has data for it in shared storage The First time I do this all is well The Second time around I have created a modless dialog box with a Crichedit control it is at this time where I get a asseration from the SendNotifyMessage in the console C app The assetration is dlgcore.cpp at the parent GetSafeHWnd
lpDialogTemplate = (DLGTEMPLATE\*)GlobalLock(hTemplate); // setup for modal loop and creation m\_nModalResult = -1; m\_nFlags |= WF\_CONTINUEMODAL; // create modeless dialog AfxHookWindowCreate(this); hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, **pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG**
dwError = ::GetLastError();
#endif
}
CATCH_ALL(e)
{ -
pParentWnd
is NULL or the window has not yet been created (it'sHWND
member is NULL). I can give no more help because you did not show the relevant code parts (the posted code seems to be MFC source). -
Why are you using
pParentWnd->GetSafeHwnd()
to get your HWND? You should just useGetSafeHwnd()
on its own. -
It gets to dlgcore by virtue of your call to
SendNotifyMessage
, at which point it asserts because the handle you sent it is not valid. -
But the Window Handle is a Main or Mainframe Window I did a FindWindow api call To get the handle As the parent is a C console app and it did work once before I created the modless dialog box in the child process
-
But you are calling
pParentWnd->GetSafeHwnd()
in a console app which makes no sense. What doespParentWnd
point to? -
Hi I am at work now however the only thing I can think of at this point is that I have to use DuplicateHandle to make the child main window accessible to the parent
No, you just need to find its handle by one of the enumerate functions, or get the child to pass it back in some way. A handle is just a pointer used to identify a Window so you can send messages to it. To be honest, I am not exactly clear about what you are trying to do beyond the basic SendMessage function.
-
No, you just need to find its handle by one of the enumerate functions, or get the child to pass it back in some way. A handle is just a pointer used to identify a Window so you can send messages to it. To be honest, I am not exactly clear about what you are trying to do beyond the basic SendMessage function.
-
"EnumThreadWindows" My questions in Windows is a threadID unique throughout Windows Thanksp
-
I would assume yes, since in the case of
EnumThreadWindows
, the threadid is the only information Windows needs to return the information. -
Richard got the same assertion I believe this has to do with sharing window handles between threads I am going to use duplicate handle and see if that resolves the issue Thanks