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 function is used to retrieve the currently selected index in a list box?

2 Answers  


How many types of combo box are their

2 Answers   Aaditya Info Solutions, E Logic,


Hi All, I have created one MFC Dialog Based application.now if i am running the application its working fine,instead of closing he application i minimized the application,if i run the application again,i am getting the Dialog. I want to prevent the calling of application multiple times. please give me the code and let me know in which method i need to make changes. Praveer

7 Answers   HP,


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

2 Answers  


What types of threads are supported by MFC framework?

2 Answers  






if both base and derived class have the constructors if i create an object for derive class which class constructor is executed first

10 Answers   Siemens, Symphony,


I have 2 threads. One thread prints odd numbers and the second thread prints even numbers. Now, I have to execute the threads alternatively so that i can output 1,2,3,4,5,6,..... write code for this?

1 Answers  


1)How to load an icon on a button as Dynamically ?

1 Answers   HCL,


1)dynamic creation of a Button ?

2 Answers   TCS,


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

2 Answers   Soltius Infotech,


What are the differences between MFC Exception macros and C++ exception keywords?

2 Answers  


i have created runtime menu -- ( admistrator ->managepackage,manage module). but now i want to open a dialog when i select manage package and any other diaolg when selecting manage module ( whole selection is at run time only ) . Please HELP .its urgently required

3 Answers   Patni,


Categories