Microsoft Foundation Class Library (MFC) Interview Questions & Answers

Microsoft Foundation Class Library (MFC) Interview Questions

Microsoft Foundation Class Library (MFC) is the library in C++ which is used to create or develop applications for desktop. MFC is developed by Microsoft and became popular after its release. This library is the collection of classes used in applications. Developers can use the library to write new applications. Candidates should have knowledge on Microsoft Foundation Class Library (MFC) concepts and developing mobile apps. There are number of positions available across all the locations. Wisdomjobs focus on providing interview questions and answers to help you in clearing the interview with ease. Microsoft Foundation Class Library (MFC) interview questions and answers are useful to attend job interviews and get shortlisted for job position. Check out interview questions page to get more information.

Microsoft Foundation Class Library (MFC) Interview Questions And Answers

Microsoft Foundation Class Library (MFC) Interview Questions
    1. Question 1. Whats Is Ddx & Ddv In Mfc?

      Answer :

      Dialog data exchange (DDX) is an easy way to initialize the controls in your dialog box and to gather data input by the user. Dialog data validation (DDV) is an easy way to validate data entry in a dialog box.

    2. Question 2. What Is Synchronization Objects Types And Where We Are Using In The Code?

      Answer :

      CRITICAL_SECTION :- CRITICAL_SECTION (CS) objects are initialized and deleted but do not have handles and are not shared by other processes. A variable should be declared to be of type CRITICAL_SECTION. Threads enter and leave a CS, and only one thread at a time can be in a specific CS. EnterCriticalSection blocks a thread if another thread is in the section. The waiting thread unblocks when another thread executes LeaveCriticalSection. If a thread already owns the CS, it can enter again without blocking; that is, CRITICAL_SECTIONs are recursive. CRITICAL_SECTIONs have the advantage of not being kernel objects and are maintained in user space. This usually, but not always, provides performance improvements.

      Mutex: - mutexes can be named and have handles, they can also be used for interprocess synchronization between threads in separate processes. Mutex objects are similar to CSs, but, in addition to being process-sharable, mutexes allow time-out values and become signaled when abandoned by a terminating process.A thread gains mutex ownership (or locks the mutex) by waiting on the mutex handle (WaitForSingleObject or WaitForMultipleObjects), and it releases ownership with ReleaseMutex. 

      Semaphore :- Semaphores maintain a count, and the semaphore object is signaled when the count is greater than 0. The semaphore object is unsignaled when the count is 0. 

      Event :- Events are used to signal other threads that some event, such as a message being available, has occurred.

    3. Question 3. What Is The Flow Of Sdi Application?

      Answer :

      CwinApp -> CDocument -> CFrameWnd -> CView

    4. Question 4. What Is The Base Class For Mfc Framework?

      Answer :

      CObject class.

    5. Question 5. What Is Model And Modeless Dialog Box? Give Some Examples?

      Answer :

      Modal dialog is one which will not allow u to access any thing until this dialog is active.



      And reverse of this ur modeless dialog.


      For Example: 

      Modal Dialog:

      When we access Menu items such as Save as, Open, attach file, in any application, we can not able to access any part of the application execpt the active dialog.

      When we open add remove program for uninstalling any application, u will get a Uninstallation dialog which will be modeles. bcz still u were able to access add remove programs. (this is probably in Vista. And in XP its modal dialog which they have used)

    6. Question 6. What Is The Use Of Cwinapp Class?

      Answer :

      CWinApp is an application object provides member functions for initializing your application (and each instance of it) and for running the application.

      Each application that uses the Microsoft Foundation classes can only contain one object derived from CWinApp. This object is constructed when other C++ global objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the Microsoft Foundation Class Library. Declare your derived CWinApp object at the global level.

      When you derive an application class from CWinApp, override the InitInstance member function to create your application's main window object. 

      In addition to the CWinApp member functions, the Microsoft Foundation Class Library provides the following global functions to access your CWinApp object and other global information: 

      • AfxGetApp Obtains a pointer to the CWinApp object.
      • AfxGetInstanceHandle Obtains a handle to the current application instance.
      • AfxGetResourceHandle Obtains a handle to the application's resources.
      • AfxGetAppName Obtains a pointer to a string containing the application's name. Alternately, if you have a pointer to the CWinApp object, use m_pszExeName to get the application's name.

    7. Question 7. What Is Stack Size In Win32 Program?

      Answer :


    8. Question 8. How Can Update Edit Control Data Of An Executing Application From Other Application?

      Answer :

      First, need to find the handle of the Control by using some API like EnumWindows and enumerrating all windows and checking for the text of the window by GetWindowTExt.

      Once, handle of the target control has been identified, SendMessage can be used to send appropriate message to the control. like WM_SETTEXT can be sent to change text of window, etc...

    9. Question 9. If Application Hangs While Sendmessage Is Waiting For The Result, How You Handle It?

      Answer :

      Instead of SendMessage API i will use the SendMessageTimeout 

      API to solve the system hang or You can use PostMessage API instead.

    10. Question 10. How You Find Memory Leaks?

      Answer :

      There many ways to find memory leaks, One of the ways is by using MFC class. And another way is using Purify tools...

      CMemorState is a MFC class by which we can find the memory leaks. Below is a sample code to find the same.

      #ifdef _DEBUG
      CMemoryState oldState, newState, diffState;
      int* a = new int[10];
      #ifdef _DEBUG 
      if(diffState.Difference(oldState, newState))
      TRACE0("Memory Leaked");

    11. Question 11. What Is The Base Class For Mfc?

      Answer :

      CObject is the base class for all the MFC classes.

    12. Question 12. What Is Primitive And Non-primitive Application?

      Answer :

      primitive & non-primitive type are difference thing,primitive is the well defined data,we can't modified this type of data,but in non-primtive type as a user defined of data which store reference or object data,bcz they are created rather then per-defind.

    13. Question 13. General Purpose Classes In Mfc?

      Answer :

      CString, CSize, CPOint..

    14. Question 14. What Is The Use Of Ccmdtarget?

      Answer :

      CCmdTarget class used to process window message, any class directly or indirectly inherited from CCmdTarget will eligible for message handling..

    15. Question 15. List Out The Basic Features Of Mfc?

      Answer :

      new container 
      polymorphic wrapping 
      expression passing 
      Smart Pointer

      1. Application Framework: The MFC library framework includes its own application structure-one that has been proved in many software environments.App wizard generates skeleton code for your entire application, and class wizard generates prototypes and function bodies for message handlers.
      2. Message Mapping
      3. Runtime class information
      4. Serialization

    16. Question 16. List Out The Parameters Of Winmain Function?

      Answer :

      int CALLBACK WinMain(
      __in HINSTANCE hInstance,
      __in HINSTANCE hPrevInstance,
      __in LPSTR lpCmdLine,
      __in int nCmdShow

    17. Question 17. How We Call A Dialog In Another Dialog?

      Answer :

      Using DoModal() function.
      create a class of another dialog box.
      and write a code in fist dialog box function.
      Classname(second) variable_name;
      and define the new header file in fisrt dialog bob code.
      #include "classname.h"

    18. Question 18. How To Find The Mouse Entering An Image And While Entering Need To Display Next Image?

      Answer :

      by using the tool tip property we can know the where the mouse point is located now.

    19. Question 19. What Is Ctargetobject?

      Answer :

      In general, TargetObject is the object where you will get the sorted result.

      If you want to specific answer please update the context and details of question like Grid or Array.

    20. Question 20. How To Update Windows Title Bar Dynamically?

      Answer :

      using SetWindowText()function we can change text of specified window dynamically.

Popular Interview Questions

All Interview Questions

All Practice Tests

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Microsoft Foundation Class Library (MFC) Tutorial