Solved

EVENTSINK_MAP for a ctrl passed in at runtime

Posted on 1998-07-08
6
367 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 300 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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