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.
Name the Synchronization objects ?
Following are the synchronization objects
1) Critical Section
2) Event
3) Mutex
4) Semaphore
Classes provided for above synchronization objects are:
1) CCriticalSection
2) CEvent
3) CMutex
4) CSemaphore
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:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
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.
Why wizards generate enum IDD for dialogs?
It's good programming practice to do it this way, as from the client code you can always refer to the CMyDlg::IDD without worrying what the actual constant is.
What is the base class for MFC Framework ?
CObject
What is the use of CCmdTarget ?
It is the base class for the MFC library message map architecture.Which maps commands/messages to the member functions to handle them. Classes derived from this are CWnd,CWinApp,CFrameWnd,CView, CDocument .
What is document-view architecture ? Give me one real time example for SDI ?
Document/view architecture, which defines a program structure that relies on document objects to hold an application's data and on view objects to render views of that data. MFC provides the infrastructure for documents and views in the classes CDocument and CView.
example of SDI is a wordpad application
Can you explain the relashionship between document,frame and view ?
The frame window is the application's top-level window. It's normally a WS_OVERLAPPEDWINDOW-style window with a resizing border, a title bar, a system menu, and minimize, maximize, and close buttons.
The view is a child window sized to fit the frame window so that it becomes the frame window's client area.
The application's data is stored in the document object, a visible representation of which appears in the view.
For an SDI application, the frame window class is derived from CFrameWnd, the document class is derived from CDocument, and the view class is derived from CView or a related class such as CScrollView.
How to access document object from view ?
Using GetDocument() function within a CView class.
What is the entry point for window based applications ?
WinMain() is the entry point for window based applications.
What is model and modeless dialog box ? Give some examples?
When we create Modal Dialog Box we can't move to other windows until this dialog is closed. For eg: MessageBox, where we can't move to the other window until we press ok or cancel.
When we create Modeless Dilaog Box we can swap to the other windows. For eg: like a conventional window.
How to create open & save dialogs ?
In CommonDialogs class we have to use CFileDialog class where the first parameter TRUE for open dialog and FALSE for Save dialog.
For file open:
CFileDialog SampleDlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt|Comma Separated Values(*.csv)|*.csv||");
int iRet = SampleDlg.DoModal();
No comments:
Post a Comment