Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I receive notification of a change in the value of a dynamically created user interface object?

I need to know when the user has changed the value of a slider or a Boolean control that was dynamically created (not part of a dialog). Is there any way to do that without polling? I would have expected these controls to post a WM_NOTIFY message to the parent window in response to user events, but that does not seem to happen. Am I missing something?
0 Kudos
Message 1 of 4
(3,302 Views)
Win32 controls do typically post WM_NOTIFY messages to the parent window for user events. The Measurement Studio UI controls are actually ActiveX controls, though, and events are handled differently for ActiveX controls.

If you have a resource ID for you control, the easiest way would be to create your control in the OnInitDialog method and handle the event the same way you would if you had added the control to the dialog at design-time:


  1. Add a declaration for the event handler in the AFX_MSG block in the dialog header file.

  2. Make sure the AFX_MSG block in the header file includes DECLARE_EVENTSINK_MAP()

  3. Include an ON_EVENT entry for the event in the dialog source's BEGIN_EVENT_SINK_MAP block.

  4. Include a DDX_Control entry
    in the dialog source's AFX_DATA_MAP block.



Otherwise, you'll have to dynamically sink the event at runtime after you've created the control. Microsoft's Knowledge Base has a couple of good articles that demonstrate how to do this:

SAMPLE: AtlEvnt.exe Creates ATL Sinks Using IDispEventImpl (Q194179)
AtlSink Uses ATL to Create a Dispinterface Sink (Q181277)

- Elton
0 Kudos
Message 2 of 4
(3,302 Views)
Elton,

Thanks for the reply. I have to confess that I do not know a lot about ATL. I am using MFC in my project, which is a DLL that shows a window (not a dialog) on which I allow the user to dynamically create Measurement Studio UI controls. Do you know whether the techniques described in the Microsoft articles would apply?

Thanks.

Wayne
0 Kudos
Message 3 of 4
(3,302 Views)
Since your UI is on a window and not a dialog, the resource ID approach that I described above won't work. The information in the KB articles above should work, though - the main thing is that you have to implement an event sink. I recommend trying the steps in the IDispEventImpl section from Q194179.

- Elton
0 Kudos
Message 4 of 4
(3,302 Views)