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

x
?
Solved

Passing values by firing custom events

Posted on 2001-07-23
7
Medium Priority
?
509 Views
Last Modified: 2013-11-20
I have an ACtive-X called Picker.I want to fire event to the container application,so that the container app can receive an integer value when ever event is fired.Now i have created Custom event and iam passing an interger value to client.The problem is iam able to fire the event but not able to get correct integer value passes by the ACtive-x to the container.The listing is as follows.

Picker.h (ACtive-x module)

class CSelectorCtrl : public COleControl
{
     DECLARE_DYNCREATE(CSelectorCtrl)

// Event maps
     //{{AFX_EVENT(CSelectorCtrl)
     void FireSelectionChanged()
          {FireEvent(eventidSelectionChanged,EVENT_PARAM(VTS_NONE));}
     void FireAlert(int lIndex)
          {FireEvent(eventidAlert,EVENT_PARAM(VTS_I2));}
     //}}AFX_EVENT
     DECLARE_EVENT_MAP()

// Dispatch and event IDs
public:
     enum {
     //{{AFX_DISP_ID(CSelectorCtrl)
     dispidView = 1L,
     dispidColumnWidths = 2L,
     dispidSetDisplayList = 3L,
     dispidSetSelectionList = 4L,
     dispidCopy = 5L,
     dispidSort = 6L,
     dispidSelectAll = 7L,
     dispidReset = 8L,
     eventidSelectionChanged = 1L,
     eventidAlert = 9L,
     //}}AFX_DISP_ID
     };


};

Picker.cpp (ACtive-X module)

BEGIN_EVENT_MAP(CSelectorCtrl, COleControl)
     //{{AFX_EVENT_MAP(CSelectorCtrl)
     EVENT_CUSTOM("Alert", FireAlert, VTS_I2)
     //}}AFX_EVENT_MAP
END_EVENT_MAP()

void CSelectorCtrl::PassValue
{

FireAlert(entity.GetEntityId());// event fired along with int value

}

//////////////////////// container /////////////////////
Entity.h

class CEntityView : public CView
{

// Form Data
public:
     //{{AFX_DATA(CEntityView)
     enum { IDD = IDD_ENTITY_LIST };
     CSelector     m_Selector;// object of Active-x derived from CWnd
     //}}AFX_DATA

afx_msg void OnAlert(long lEntityID


};

 Entity.cpp

BEGIN_EVENTSINK_MAP(CEntityView, CFormView)
    //{{AFX_EVENTSINK_MAP(CEntityView)
     ON_EVENT(CEntityView, IDC_SELECTOR, 2 /* Alert */, OnAlert, VTS_I2)
     //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CEntityView::OnAlert(int nEntityID)
{
// Here i get interger value from the ACtive-X

}

How do i get the correct value from the event fired by the ACtive-x

0
Comment
Question by:gymsam
[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
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6308352
> ON_EVENT(CEntityView, IDC_SELECTOR, 2 /* Alert */, OnAlert, VTS_I4)
   
should this be VTS_I2 you seem to be using that elsewhere
0
 

Author Comment

by:gymsam
ID: 6310965
>>ON_EVENT(CEntityView, IDC_SELECTOR, 2 /* Alert */, >>OnAlert, VTS_I2)

sorry its VTS_I2 in my container application
   

   
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6311340
void FireAlert(int lIndex)
         {FireEvent(eventidAlert,EVENT_PARAM(VTS_I2),lIndex);}

the docs seem to only show it with 2 parameters however it is actually got ... which means it has variable arguments imilar to printf

void AFX_CDECL FireEvent(DISPID dispid, BYTE* pbParams, ...);
   
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:gymsam
ID: 6311524
Explain clearly what changes i have to do in my code.
0
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 200 total points
ID: 6311670
your firealert code looks like this

> void FireAlert(int lIndex)
>         {FireEvent(eventidAlert,EVENT_PARAM(VTS_I2));}

I think it should look like this

void FireAlert(int lIndex)
        {FireEvent(eventidAlert,EVENT_PARAM(VTS_I2),lIndex);}

0
 

Author Comment

by:gymsam
ID: 6315513
Your are exactly right.thank you very much.Take you bite.
0
 

Author Comment

by:gymsam
ID: 6315514
Thanks for participating.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 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