?
Solved

Passing values by firing custom events

Posted on 2001-07-23
7
Medium Priority
?
499 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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