Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is the equavilent RaiseEvent of VB in MFC?

Posted on 1998-10-14
3
Medium Priority
?
517 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

636 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