Solved

What is the equavilent RaiseEvent of VB in MFC?

Posted on 1998-10-14
3
503 Views
Last Modified: 2013-11-20
In VB, u can raise a user-defined event by RaiseEvent...
e.g. in VB
Event XX
Sub YYYY
   .......
   RaiseEvent XX
End Sub

May I know how to do so in MFC??? Please provide a full working sample code as well....

Though I could not afford much points but I promise good grade.... :-)
0
Comment
Question by:samyee
3 Comments
 
LVL 2

Expert Comment

by:chris_a
ID: 1323292
Use class wizard to add the event, then you just call the procedure it creates
0
 
LVL 1

Accepted Solution

by:
amby earned 50 total points
ID: 1323293
2 cases:
 1 - OCX (or ActiveX control):
create your event with ClassWizard (ctrl+w, got to 'automation' tab for the right project/class, button 'add event')
in the program, call Fire... where ... is the name of the event (by default), with parameters.

 2 - Standard project, win32 or MFC:

you can use window messages:
define a new message:
#define MY_MSG  WM_APP + 1

to cath the event, in the class definition file (.h), add

afx_msg long OnMyMsg(WPARAM wParam, LPARAM lParam);

in the implementation file (.cpp), find
BEGIN_MESSAGE_MAP(...)
where ... is the name of the class
just below the found line, add
ON_MESSAGE(MY_MSG, OnMyMsg)

(do not finish this line with a ';')

at the bottom of the implementation file, define the message handler

long ...::OnMyMsg(WPARAM wParam, LPARAM lParam)
{
    the_code_you_want_to_handle_the_message();
}

both are valid only for CWnd-derived objects (= any window)
0
 

Author Comment

by:samyee
ID: 1323294
Thanks a lot!!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 63
tripleUp challenge 7 86
Problem to App 4 97
moto 4g phone enable finger print 4 26
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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