MFC Interview Preparation Guide
Download PDF

Microsoft Foundation Class (MFC) frequently Asked Questions in various MFC job Interviews by interviewer. Get preparation of Microsoft Foundation Class (MFC) job interview

26 MFC Questions and Answers:

2 :: How to update windows title bar dynamically?

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

3 :: What is CTargetObject?

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

4 :: How to find the mouse entering an image and while entering need to display next image?

BY USING THE TOOL TIP PROPERTY WE CAN KNOW THE WHERE THE
MOUSE POINT IS LOCATED NOW.

5 :: How we call a dialog in another dialog?

Using DoModal() function.
create a class of another dialog box.
and write a code in fist dialog box function.

Classname(second) variable_name;
variable_name.DoModl();

and define the new header file in fisrt dialog bob code.
like;
#include "classname.h"

6 :: List out the parameters of WinMain Function?

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

7 :: How to create a button dynamically?

1. Create a Object from CButton control. CButton m_ctlButton
2. m_ctlButton.Create("OK",ES_CHILD|ES_VISIBLE,CRect(0,0,100,100),CWnd*
pParentWnd,MB_OK);

with this we can create the button by dynamically.

8 :: What is a message map?

Message map is dynamic function locater
It can look each function if it defined

e.g

void OnWndMessage(UINT message, WPARAM wParam, LPARAM
lParam, LRESULT *pResult)

{
// function looking MESSAGE_MAPS ((DECLARED))
// if found, CWnd::OnSize(UINT nStyle, int cx, int cy);
__thisclass.OnSize(wParam, HIWORD(lParam), LOWORD(lParam);
}
//M

9 :: List out the basic features of MFC?

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

10 :: How to give color for dialog button or static buuto?

Brush *brush;
Initialize the brush pointer in the constructor of your Dialog
Code:
brush = new CBrush(RGB(49,49,49));
Add the WM_CTLCOLR Message handler for the dialog and add the following code
Code:
switch (nCtlColor) {

case CTLCOLOR_BTN:
pDC->SetTextColor(RGB(0, 255, 0));
pDC->SetBkColor(RGB(0, 0, 0));
return (HBRUSH)(brush->GetSafeHandle());
default:
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}