Solved

What is the equavilent RaiseEvent of VB in MFC?

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

Industry Leaders: 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!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

690 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