Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

EVENTSINK_MAP for a ctrl passed in at runtime

Posted on 1998-07-08
6
Medium Priority
?
426 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 1318868
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
ID: 1318869
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
ID: 1318870
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:skin
ID: 1318871
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
ID: 1318872
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 1200 total points
ID: 1318873
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

609 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