Skip to main content

Posts

Showing posts with the label MFC

What types of threads are supported by MFC ? How they can be created ?what is the difference between them?

1. Worker Threads. Provide only background processing. Doesn't handle messages. Creation: By calling AfxBeginThread() and providing a global function as a parameter. 2 UI Threads. These threads have the UI (Window) and can process the messages, i.e. user interaction (I/O) with window. Creation: By calling AfxBeginThread() and providing a class which is derived from CWinThread and implements all message handling mechanism as a parameter.

Name few classes in MFC which are not derived from CObject class ?

ActiveX Type Wrappers CFontHolder CPictureHolder Automation Types COleCurrency COleDateTime COleDateTimeSpan COleVariant Run-Time Object Model Support CArchive CDumpContext CRuntimeClass Simple Value Types CPoint CRect CSize CString CTime CTimeSpan structures CCreateContext CPrintInfo CRunTimeClass Support Classes CCmdUI CDataExchange CLongBinary COleDispatchDriver CPropExchange Synchronization Support CSingleLock CMultiLock CRectTracker CWaitCursor Typed Template Collections CTypedPtrArray CTypedPtrList CTypedPtrMap Windows CE Database Classes CCeDBEnum CCeDBRecord.

Explain modal and modeless dialog box ? what is the difference between modal and modeless dialog box ?

A modal dialog box is popped up over the parent dialog( from which it is envoked) it never allows user to go back to parent (calling) dialog box and work until the popped up dialog box is not exited. Madal dilog box can be displayed as follows. Ex. class MyDlg; // Class derived from CDialog. MyDlg myDlg; // create an object myDlg.DoModal(); A modaless dialogbox is on user can move back and forth between the poped up dialogbox and the parent (calling dialog) For creating a modless dialogbox. needs to follow follwing things. Ex. class MyDlg; // Class derived from CDialog. MyDlg myDlg; // create object myDlg.create(uint DialogId); // Call create method by providing the dialog resource id. provide the message handling and run loop. Difference between modal an modaless dialog box. modal doesnt allow user to go back to parent window and work in it untill it is not exited while modeless allows to work in parent window. Other differnce is of creation and displaying of dialog object.

What is a DLL ? What are different dll's supported in VC++ ? Explain different types of dll's.

A DLL is a dynamic link library. It provide a way of sharing common code at runtime . Any appication( exe) can load a dll in to memory at runtime, retrieving the address of the fuctions to be called / accessing resources or variables. client can use the functions, variable or resources and unloads the dll from memory. One can load the dlls either statically or dynamically. Dynamically loading - HANDLE h = LoadLibrary("MyDll.dll"); // load dll typedef FUNPTR (void) (*funcPtr ) (); // create a fuction pointer with matching signature // with that of exported function from dll. FUNPTR show = GetProcAddress( h, "Show"); // Get function address show(); // Call the fuction FreeLibrary(h); // unload dll from memory Statically loading: Include the .h file and specify .lib file to the linker for specified dll. User can access the dll content ( Exported fuctions, resources, variables) at compile time itself. Regular, Extension and pure Win32 DLL (without MFC) Regular DLL Regul...

What is the use of SendMessage() and PostMessage() ? what is the difference between SendMessage() and PostMessage() ?

These are theWin32 API's provided to send a message to window Or a way to notify a window to perform some action. SendMessage() - This message is sent directly to the window. It means it doesn't return until, the "sent message" is not processed( Message handler is not executed). PostMessage() - This message is sent to the application message queue, from where application will pick up the message later on, gets processed. This API returns immediately as soon as it posts the message to message queue. It never waits for the respective message handler to be executed.

What is the top base class for MFC Framework? If I derive a new class from CObject class what are the basic features my derived will get? OR what are

CObject If I derive a new class from CObject class what are the basic features my derived will get? OR what are the main features provided by CObject class? Answer: a) Runtime class identification– know the objects class type at runtime. b) Dynamic object creation.– Create object at runtime. c)Serialization - Storing object to disk or reading object from disk d)Diagnostic support. – provide debug information such as trace, memory dump.

MFC - Microsoft Foundation Classes, GUI Development

Are you ready to start programming? No you are not. You don't want me to teach you a stupid 'hello world' application, do you? If you want to make the most of Visual C++ you have to use Microsoft Foundation Classes (MFC). These classes are great because they wrap all of those handles we talked about in the first lesson with easy to use classes. The most important to you right now is the class CWnd . This wraps the functions which needed a window handle ( HWND ). Remember that PostMessage function I mentioned? PostMessage(your_HWND, WM_PAINT, 0,0); Well now we can take our windows class and call it's member function. MyCWnd.PostMessage(WM_PAINT, 0,0); This does the same thing, but now we don't have to keep track of the window handles. But don't be fooled, they are still there. We can still use them too. They are now just member variables of the class. The handle to the window a CWnd is associated with in the member variable m_hWnd . We can...