0
votes

I dynamically create some ActiveX controls in my MFC app. I want to handle their event such as click, dblclick. But I don't know what kind of message should I catch where to put the code to catch them. I can add the event handler if I put the these control on the dialog window as I design the GUI. The code automatically added by MFC is below:

BEGIN_EVENTSINK_MAP(CButtonMsgDlg, CDialog)
    ON_EVENT(CButtonMsgDlg, IDC_CWBOOLEAN1, DISPID_DBLCLICK,   CButtonMsgDlg::DblClickCwboolean1, VTS_NONE)
END_EVENTSINK_MAP()

void CButtonMsgDlg::DblClickCwboolean1()
{
   // TODO: Add your message handler code here
}
1
// TODO: Add your message handler code here seems like a pretty good indication to me. You can do the same thing for dynamically created controls just manually add ON_EVENT/ON_COMMAND/etc with the id you will use in the control creation. You can also use a range of ids if needed.AJG85
There are hundreds of controls need to be created dynamically. And the IDs of these control are assigned at run time. So Add them manually before compiling seems impossible. Is there any other way to tackle this problem?gomypig

1 Answers

0
votes

If you already know the event type at compile time, but don't know the control ids, check How to create a sink interface in a MFC-based COM client