Solved

Passing values by firing custom events

Posted on 2001-07-23
7
470 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
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 77
zeroFront challenge 7 111
How to convert MFC::CString to UTF8 wchar_t* 10 275
JQuery serialize and unserialize 8 132
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 …
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.

792 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