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

I can i set size of integer variable should be fixed for different operating systems(Ex i want integer size is 2bytes in OS)

2 Answers   Invensys,


Hi All, i am new for VC++ SDK. i want to get the IP Address of all the External device connected with my local machine.please give the code Regards, Praveer

1 Answers   TCS, Tech Mahindra,


What interface must be supported by an ActiveX control?

2 Answers  


What is CArchive class dowes?

4 Answers  


Explain in sort What is CTargetObject?

2 Answers  






What is a message map, and what is the advantage of a message map over virtual functions?

1 Answers  


What is Multithreading

1 Answers   Invensys,


Explain the flow of SDI application?

8 Answers   Mphasis,


Does the application have more than one object? If Yes, Briefly explain.

2 Answers   Soltius Infotech,


Tell me the different controls in MFC ?

5 Answers  


what is the component of CLR ?

8 Answers   AZTEC, Symphony,


If there is more than 100 control in a window how we can change the Taborder of a controls

4 Answers   Satyam,


Categories