Solved

EVENTSINK_MAP for a ctrl passed in at runtime

Posted on 1998-07-08
6
382 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 217
wait notify demo infinite loop 3 121
Line meaning 9 87
wordappend challenge 8 199
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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