Solved

What is the equavilent RaiseEvent of VB in MFC?

Posted on 1998-10-14
3
502 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 139
move a line in eclipse 3 104
Hibernate methods 2 73
JQuery serialize and unserialize 8 91
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

831 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