Solved

EVENTSINK_MAP for a ctrl passed in at runtime

Posted on 1998-07-08
6
342 Views
Last Modified: 2013-11-20
I'm trying to setup an EVENTSINK_MAP for a control that is passed in at runtime.  The problem is that the ON_EVENT macro's second parameter is the control's ID.  I figure that I can put a dummy there and change it by setting _eventsinkEntries[n].nCtrlIDFirst where n is the ordinal number of the ON_EVENT macro.  The problem is getting the the control ID from the custom control that is passed in.
Any ideas?
0
Comment
Question by:skin
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
What you're thinking of doing is the long way around.

You should override OnCmdMsg() and watch for event notifications from the control.

My book has an elaborate sample that shows how to do this, as well as other issues associated with containing controls at runtime in MFC applications.

B ekiM

0
 

Author Comment

by:skin
Comment Utility
Oops I should have been clearer in my description.  I have a control, I'll call A.OCX that exposes a write-only automation property for accepting an LPDISPATCH of another Control, B.OCX.  I need A.OCX to be able to receive notification when B.OCX fires certain events.  I bought your book last night and overrode OnCmdMsg() but do not see anything in OnCmdMsg().  
0
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
Is A.OCX containing B.OCX?  Or are they side-by-side in the container?

If A.OCX contains B.OCX, then OnCmdMsg() will work fine: you must've made a mistake.

If they're side-by-side in the container, you can't do what you want. You need to code smarts into the container to reflect notifications from one control to all controls. The OLE Control spec has no provision for one control to spy on the invocations of another control--and that makes sense, since the Windows control model doesn't support it, either.

B ekiM



0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:skin
Comment Utility
Actually B.OCX creates A.OCX.  
B.OCX may be created on a VB form and in turn creates A.OCX.
I need A.OCX to be able to watch B.OCXs events and take actions to update itself in response to changes in B.OCX.
Because when A.OCX is created it is passed an Dispatch pointer to B.OCX.
I figured there must be some way to sink A.OCXs events.
Thanks for your continued help!  If this still sounds like it's impossible I'll close this one.
0
 

Author Comment

by:skin
Comment Utility
MiksBlas,

Assuming this can not be done as per your last repsonse, if you reply again I'll close this.
Thanks.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 300 total points
Comment Utility
You _can_ do it, if you control the container. Then, you're responsible for the container having an interface that tells controls it contains about other controls it contains.  It's up to you to make that interface, and it's also up to you to make sure your controls gracefully degrade when they're inserted into containers which don't provide that custom interface.

B ekiM
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now