Ben Voigt [C++ MVP]
6/29/2007 7:37:00 AM
<aaron.m.johnson@gmail.com> wrote in message
news:1182982181.058574.225460@a26g2000pre.googlegroups.com...
> I'm writing a C# control that needs to be able to notify the parent
> application of certain events. If the application were also using
> the .NET platform I'd just use a delegate. Unfortunately the
> application is writen in unmanaged C++.
>
> Is there some way for me to send a message or execute a callback from
> the control that the application can process?
>
For a GUI control, post a notification message to the parent window (see
WM_NOTIFY, BN_CLICKED for example).
For non-GUI components, a function pointer is much like a delegate.
Remember to include an extra parameter set at the time of subscription,
sizeof void* or larger, for the caller to pass his "this" pointer or some
other data he wants.