Solved

Passing values by firing custom events

Posted on 2001-07-23
7
487 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
Independent Software Vendors: 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!

 

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 50 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 118
method notes when mouse over in eclipse 5 94
java ^ examples 8 73
Path of Workbook 3 87
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.

739 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