YouTube Icon

Interview Questions.

Top 20 Microsoft Foundation Class Library (mfc) Interview Questions - Jul 26, 2022

fluid

Top 20 Microsoft Foundation Class Library (mfc) Interview Questions

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

First, need to find the manage of the Control by way of using a few API like EnumWindows and enumerrating all windows and checking for the textual content of the window with the aid of GetWindowTExt.

Once, cope with of the target manage has been recognized, SendMessage can be used to send appropriate message to the control. Like WM_SETTEXT can be despatched to alternate textual content of window, and so on...

Q2. How We Call A Dialog In Another Dialog?

Using DoModal() characteristic.

Create a category of another dialog container.

And write a code in fist conversation field characteristic.

Classname(2d) variable_name;

variable_name.DoModl();

and outline the new header document in fisrt conversation bob code.

Like;

#consist of "classname.H"

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

Instead of SendMessage API i will use the SendMessageTimeout 

API to solve the machine hang or You can use PostMessage API as an alternative.

Q4. What Is The Flow Of Sdi Application?

CwinApp -> CDocument -> CFrameWnd -> CView

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

By way of the use of the tool tip belongings we will recognize the wherein the mouse factor is located now.

Q6. List Out The Basic Features Of Mfc?

New box 

polymorphic wrapping 

expression passing 

Smart Pointer

Application Framework: The MFC library framework consists of its very own utility shape-one which has been proved in lots of software program environments.App wizard generates skeleton code to your complete application, and class wizard generates prototypes and characteristic bodies for message handlers.

Message Mapping

Runtime elegance records

Serialization

Q7. What Is The Base Class For Mfc Framework?

CObject class.

Q8. How To Update Windows Title Bar Dynamically?

The use of SetWindowText()characteristic we can alternate textual content of targeted window dynamically.

Q9. What Is The Use Of Ccmdtarget?

CCmdTarget magnificence used to system window message, any magnificence immediately or circuitously inherited from CCmdTarget will eligible for message dealing with..

Q10. General Purpose Classes In Mfc?

CString, CSize, CPOint..

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

CRITICAL_SECTION :- CRITICAL_SECTION (CS) gadgets are initialized and deleted but do no longer have handles and are not shared via other tactics. A variable must be declared to be of type CRITICAL_SECTION. Threads enter and depart a CS, and simplest one thread at a time may be in a specific CS. EnterCriticalSection blocks a thread if some other thread is inside the phase. The ready thread unblocks when any other thread executes LeaveCriticalSection. If a thread already owns the CS, it is able to enter once more without blocking; that is, CRITICAL_SECTIONs are recursive. CRITICAL_SECTIONs have the advantage of now not being kernel items and are maintained in consumer area. This commonly, but now not continually, gives overall performance improvements.

Mutex: - mutexes can be named and have handles, they also can be used for interprocess synchronization among threads in separate processes. Mutex gadgets are just like CSs, but, further to being technique-sharable, mutexes allow time-out values and turn out to be signaled whilst deserted by a terminating method.A thread profits mutex ownership (or locks the mutex) with the aid of waiting on the mutex cope with (WaitForSingleObject or WaitForMultipleObjects), and it releases possession with ReleaseMutex. 

Semaphore :- Semaphores preserve a be counted, and the semaphore item is signaled whilst the count number is extra than @The semaphore item is unsignaled when the matter is 0. 

Event :- Events are used to sign other threads that some occasion, inclusive of a message being available, has happened.

Q12. What Is Stack Size In Win32 Program?

1mb.

Q13. What Is The Use Of Cwinapp Class?

CWinApp is an software item presents member capabilities for initializing your software (and each example of it) and for jogging the application.

Each software that uses the Microsoft Foundation instructions can simplest include one object derived from CWinApp. This item is built whilst different C++ global objects are built and is already available when Windows calls the WinMain function, that is supplied by using the Microsoft Foundation Class Library. Declare your derived CWinApp object at the global level.

When you derive an utility magnificence from CWinApp, override the InitInstance member characteristic to create your software's foremost window object. 

In addition to the CWinApp member functions, the Microsoft Foundation Class Library presents the following worldwide features to get admission to your CWinApp item and other worldwide information: 

AfxGetApp Obtains a pointer to the CWinApp object.

AfxGetInstanceHandle Obtains a take care of to the current utility instance.

AfxGetResourceHandle Obtains a deal with to the utility's resources.

AfxGetAppName Obtains a pointer to a string containing the software's call. Alternately, if you have a pointer to the CWinApp item, use m_pszExeName to get the application's name.

Q14. Whats Is Ddx & Ddv In Mfc?

Dialog records change (DDX) is an smooth manner to initialize the controls in your conversation container and to gather facts input by means of the consumer. Dialog information validation (DDV) is an clean manner to validate records entry in a dialog field.

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

Modal dialog is one with a purpose to not allow u to get entry to any aspect until this dialog is lively.

Call:

Dialog::DoModal() 

And opposite of this ur modeless dialog.

Dialog::ShowDialog();

For Example: 

Modal Dialog:

When we get entry to Menu objects along with Save as, Open, connect record, in any application, we can't able to get admission to any a part of the software execpt the lively conversation.

When we open add take away program for uninstalling any software, u gets a Uninstallation dialog so as to be modeles. Bcz nevertheless u were capable of get entry to upload dispose of applications. (this is probably in Vista. And in XP its modal dialog which they have got used)

Q16. What Is Ctargetobject?

In preferred, TargetObject is the item where you'll get the taken care of result.

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

Q17. List Out The Parameters Of Winmain Function?

Int CALLBACK WinMain(

__in HINSTANCE hInstance,

__in HINSTANCE hPrevInstance,

__in LPSTR lpCmdLine,

__in int nCmdShow

);

Q18. What Is The Base Class For Mfc?

CObject is the base elegance for all of the MFC training.

Q19. How You Find Memory Leaks?

There many methods to find memory leaks, One of the methods is through using MFC class. And any other way is using Purify gear...

CMemorState is a MFC magnificence by which we are able to find the memory leaks. Below is a sample code to locate the same.

#ifdef _DEBUG

CMemoryState oldState, newState, diffState;

oldState.Checkpoint();

#endif

int* a = new int[10];

#ifdef _DEBUG 

newState.Checkpoint();

if(diffState.Difference(oldState, newState))

TRACE0("Memory Leaked");

#endif

Q20. What Is Primitive And Non-primitive Application?

Primitive & non-primitive type are distinction component,primitive is the well described information,we can not modified this type of data,but in non-primtive type as a consumer described of statistics which keep reference or object statistics,bcz they are created rather then in keeping with-defind.




CFG