Re: Sending a UserRegistered Message from a dll to the main applicaition

From: Christopher J. Holland (msnews_at_microsoft.com)
Date: 07/15/04


Date: Thu, 15 Jul 2004 14:45:21 -0700

Never mind. I didn't read the bottom. Where it only applies to 4.1.

-- 
Christopher J. Holland [!MVP]
http://www.mvps.org/vcfaq/
http://www.codeguru.com
http://www.codeproject.com
http://www.naughter.com/
http://support.microsoft.com/default.aspx
http://msdn.microsoft.com/howto/
http://msdn.microsoft.com/library/
http://www3.pgh.net/~newcomer
"Christopher J. Holland" <msnews@microsoft.com> wrote in message
news:OK%233D$qaEHA.3512@TK2MSFTNGP12.phx.gbl...
> You might be interested in this...
>
> "The following code demonstrates how to call PostThreadMessage() in the
> InitInstance() of the CWinApp-derived class using a single-threaded
> application. The principle is the same for secondary threads except that
the
> code shown here would be put in your alternate CWinThread-derived class."
>
>
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q142/4/15.asp&NoWebContent=1
>
> Maybe it is true for single threaded apps, but most apps are
multi-threaded.
>
> Regards,
> -- 
> Christopher J. Holland [!MVP]
> http://www.mvps.org/vcfaq/
> http://www.codeguru.com
> http://www.codeproject.com
> http://www.naughter.com/
> http://support.microsoft.com/default.aspx
> http://msdn.microsoft.com/howto/
> http://msdn.microsoft.com/library/
> http://www3.pgh.net/~newcomer
>
> "Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
> news:kfkdf0tlercjparh6q74rc40buu0881f49@4ax.com...
> > You can't put the handler in your CWinApp class because user-defined
> messages are not
> > routed to either CDocument or CWinApp classes.
> > joe
> >
> > On Thu, 15 Jul 2004 17:15:29 +1000, "Hugh Vaughan" <hvaughan@jacana.com>
> wrote:
> >
> > >You need to either (a) post the message to the HWND encapsulated by the
> > >applicable instance of CIOOutputDlg, or (b) move the message handler
to,
> > >say, your CWinApp class.
> > >
> > >If you have control over the interface at both ends, maybe you can pass
> the
> > >HWND of CIOOutputDlg to the DLL at the appropriate times (and, if
> necessary,
> > >nullify or invalidate it with the same or another DLL entry point when
> the
> > >window is destroyed).  Otherwise, depending on what assumptions it is
> safe
> > >to make in the context of your application, you may be able to "assume"
> the
> > >HWND in the DLL by, for example, a call to GetLastActivePopup or some
> other
> > >window access function.
> > >
> > >"Anders Eriksson" <anders.eriksson@morateknikutveckling.se> wrote in
> message
> > >news:w6krysaxxfa5.dlg@morateknikutveckling.se...
> > >> Hello!
> > >>
> > >> I have an MFC 7.1 application that uses a dll. The dll is not MFC
it's
> a
> > >> SDK DLL.
> > >>
> > >> Both the application and the dll is compiled as UNICODE.
> > >>
> > >> I want to send a user registered message from the .dll to the main
.exe
> > >>
> > >> I have used
> > >> static const UINT UWM_OUTPORT_MSG =
> > >>
>
::RegisterWindowMessage(_T("UWM_OUTPORT_{737386A0-62B1-4701-A9D5-436A8C07B83
> F}"));
> > >>
> > >> In both the .dll and the .exe
> > >>
> > >> and in the dll i do:
> > >>
> > >> PostMessage(NULL,UWM_OUTPORT_MSG,0,0);
> > >>
> > >> and in the main app I have:
> > >>
> > >> BEGIN_MESSAGE_MAP(CIOOutputDlg, CTabPageSSL)
> > >> ON_REGISTERED_MESSAGE(UWM_OUTPORT_MSG, OnOutPortMsg)
> > >> END_MESSAGE_MAP()
> > >>
> > >> LRESULT CIOOutputDlg::OnOutPortMsg(WPARAM, LPARAM)
> > >> {
> > >> // do something
> > >> }
> > >>
> > >> The OnOutPortMsg method will never be called!!
> > >>
> > >> Please help!
> > >>
> > >> // Anders
> > >
> >
> > Joseph M. Newcomer [MVP]
> > email: newcomer@flounder.com
> > Web: http://www.flounder.com
> > MVP Tips: http://www.flounder.com/mvp_tips.htm
>
>