Solved

Passing values by firing custom events

Posted on 2001-07-23
7
436 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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: 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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now