Solved

What is the equavilent RaiseEvent of VB in MFC?

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 85
Installing Microsoft R server on REDHAT or SUSE Linux 4 126
isEverywhere  challenge 19 64
Sed question 2 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

743 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

12 Experts available now in Live!

Get 1:1 Help Now