what is message loop how mfc does it internally?

Answers were Sorted based on User's Feedback



what is message loop how mfc does it internally?..

Answer / sonali dongare

In Window programming Message is the main communication.The
messaes are stored in message queue.
the way you retrieve messages from the Message Queue is by
creating a Message Loop. A Message Loop is a loop that
checks for messages in the Message Queue. once a message is
received, the Message Loop dispatches the message by
calling a Message Handler, a function designed to help the
Message Loop at processing the message.

Message loop ends when WM_QUIT messae is retrived.In Mfc
WinMain is the entry point.since mfc uses event driven
programming model The Incoming messages enter in the
message queue window procedure process that messages and
send to window ,winmain create that window and enter into
message loop ,retrive messages and dispatches them to
window procedure.Messages wait in message queue untill they
are retrived.In order to retrive and dispatch the message
winmain execute simple while loop that call
GetMessage,TranslateMessage and DispathMessage API
Functions .GetMessage retrive message from message
queue ,TranslateMessage convert keyboard message to WM_CHAR
message and DispatchMessage dispatch messages to Window
procedure. Message loop end when it retrived WM_QUIT
message.

Is This Answer Correct ?    40 Yes 3 No

what is message loop how mfc does it internally?..

Answer / mvs ravi kumar

Generally Windows programming is an event driven
programming. As and when something happens the some
message will be posted into message loop.

First of all, WinMain is the function which is being called
in windows application. This WinMain calls Initinstance of
that application and then enters the message loop.

Suppose take the case of SDI/MDI Application:
In SDI application messages are first sent it MainFrame
class, if there is no message handle in MainFrame then the
same message will be directed to CView. In the same way if
there is a handle for the message in View then the message
will be handled in the view other wise it will be directed
to CDocument. If there is message handle for the message
in Document then that handler function will be called
otherwise the message will be sent to CDocTemplate Class.
Then the message will be posed to another view if another
view exists otherwize the message will be sent to
DefWindowProc.

Is This Answer Correct ?    7 Yes 1 No

what is message loop how mfc does it internally?..

Answer / viresh chaudhari

The windows application enters the message loop within
Winmain to process various windows messages the OS posts to
a message queue.The message loop, "Loops" until its
receives a WM_QUIT message. It uses GetMessage and
PeekMessage to retrive messages and PostMessage to sent the
retrived messages to Windows procedure.

Is This Answer Correct ?    8 Yes 3 No

what is message loop how mfc does it internally?..

Answer / manjinder

Message loop exists internally in the WinMain() which is
the default function given by the MFC framework. In the
WinMain() there is one function called Run() which is
running this message loop. There are two types of window
messages .
1)Command routing: These commands come from menus,toolbars
etc.
2) Windows messages: These messages occured when some child
control of view or dialog box is used.

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More MFC Interview Questions

What are the special requirements for dialog box resources used in a form view?

2 Answers  


what are the feauters of CObject

4 Answers   Siemens, Wipro,


what message is sent to an application when the user presses the primary button?

0 Answers   University Exams,


How to update windows title bar dynamically?

7 Answers   HCL,


How you find memory leaks?

4 Answers   ABB,






what is functioning of DIalodDataXchange ..?

0 Answers  


What is the difference between Synchronous sockets and asynchronous sockets?

2 Answers  


Hi can anyone explain about the synchronization objects types and where we are using in the code.

1 Answers  


how many types of messages are their

4 Answers   E Logic, TCS,


what is the updated verssion in vc++

3 Answers   Aspect,


What is the use of UpdateData funciton ?

7 Answers  


1)does Frame Thickness in MFC?

1 Answers   winfoware,


Categories