MFC interview questions
Subject says it all.
1. What is the base class for MFC Framework ?
2. If i derive a new class from CObject what are the basic features my derived wil get ?
3. What is the use of CCmdTarget ?
4. What is document-view architecture ? Give me one real time example for SDI ?
5. Can you explaing the relashionship between document,frame and view ?
6. How to access document object from view ?
5. What is the entry point for window based applications ?
6. Explain the flow for a simple win32 based application ?
7. How to handle command line arguements from simple MFC application ?
8. What is model and modeless dialog box ? Give some examples?
9. How to create open & save dialogs ?
10.What is CSingleDocTemplate?
11.What is the difference between hinsrtance and hprevinstance in WinMain function?
12.Explaing about MDI and CMultiDocTemplate ?
13.Tell me the different controls in MFC ?
14. What is the use of OninitDialog ?
15. What is the use of UpdateData funciton ?
16.What is the difference between GetMessage and PeekMessage ?
17.How to update all the views whenver document got updated ?
18.How to handle RTTI in MFC ?
19.What is serialization ?which function is responsible for serializing data ?
20.What is CArchive class dowes?
21.What is thread & process?
22.Explain about different kinds of threads in MFC?
23.Tell me about different kinds of synchranization objects ?
24.what is the use of Mutex and critical section ?
25.What is socket?
26.What is the difference between Synchronous sockets and asynchronous sockets?
27.Have you ever used win32 APIs ?
28.What is the difference between ANSI Code and UNICODE ?
29.What is the difference between regular dlls and extended dlls?
30.what is the use of AFX_MANAGE_STATE ?
31. What’s the difference between PostMessage and SendMessage?
32. Describe the Document/View architecture.
33. What’s the difference between Modal and Modeless Dialog?
34. How to create a Modeless Dialog?
35. How to setup a timer?
36. Name the Synchronization objects.
37. What is a critical section and how is it implemented?
38. What is CMutex?
39. Given two processes, how can they share memory?
38. What is a message map, and what is the advantage of a message map over virtual functions?
40. What is the difference between ASSERT and VERIFY?
41. Why wizards generate enum IDD for dialogs? [Added by Shabbir]
I will be answering them slowly to each of them. If anyone else interested can do the same. It will be a very good resource thread for the beginer.
What is the difference between GetMessage and PeekMessage ?
GetMessage function waits for a message to be placed in the queue before returning where as PeekMessage function does not wait for a message to be placed in the queue before returning.
What’s the difference between PostMessage and SendMessage?
The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message.
The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
How to create a Modeless Dialog?
m_pModeless is a variable of type CDialog or any of its descendants.
this pointer as a paramter suggest we are creating a child dialog of the current dialog/window.
How to setup a timer?
Use the SetTimer function
Name the Synchronization objects ?
Following are the synchronization objects
1) Critical Section
Classes provided for above synchronization objects are:
What Is CMutex ?
An object of class CMutex represents a “mutex” — a synchronization object that allows one thread mutually exclusive access to a resource. Mutexes are useful when only one thread at a time can be allowed to modify data or some other controlled resource. For example, adding nodes to a linked list is a process that should only be allowed by one thread at a time. By using a CMutex object to control the linked list, only one thread at a time can gain access to the list.
To use a CMutex object, construct the CMutex object when it is needed. Specify the name of the mutex you wish to wait on, and that your application should initially own it. You can then access the mutex when the constructor returns. Call CSyncObject::Unlock when you are done accessing the controlled resource.
An alternative method for using CMutex objects is to add a variable of type CMutex as a data member to the class you wish to control. During construction of the controlled object, call the constructor of the CMutex data member specifying if the mutex is initially owned, the name of the mutex (if it will be used across process boundaries), and desired security attributes.
To access resources controlled by CMutex objects in this manner, first create a variable of either type CSingleLock or type CMultiLock in your resource’s access member function. Then call the lock object’s Lock member function (for example, CSingleLock::Lock). At this point, your thread will either gain access to the resource, wait for the resource to be released and gain access, or wait for the resource to be released and time out, failing to gain access to the resource. In any case, your resource has been accessed in a thread-safe manner. To release the resource, use the lock object’s Unlock member function (for example, CSingleLock::Unlock), or allow the lock object to fall out of scope
What is the difference between ASSERT and VERIFY?
The main difference between ASSERT and VERIFY is when you compile the release build of the program.
ASSERT will not be present in the release build version of the executables/dlls, and its expression that would have been evaluated will be deleted.
VERIFY will be present in the release build version of the executables/dlls but its expression that would have been evaluated will be left intact.
What is thread & process?
Threads are similar to processes, but differ in the way that they share resources. Threads are distinguished from processes in that processes are typically independent, carry considerable state information and have separate address spaces. Threads typically share the memory belonging to their parent process.
what is the use of AFX_MANAGE_STATE ?
By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:
This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope.
If all your resources lies in the single DLL you can even change the default handle to the DLL handle with the help of AfxSetResourceHandle function.
|All times are GMT +5.5. The time now is 03:57.|