Visual C++
PRACTICE QUIZ
Directions for using Microsoft Visual C++ 2008 Exp…
Windows Socket Faq’s
MFC – Microsoft Foundation Classes, GUI Developmen…
SDI and MDI Applications, Doc/View Architecture
Dialog Based Applications
The workspace, the VC++ IDE, Visual Studio Editor
Sample VC++ Project – Making a Data Viewer
C++ Essentials
Behind the scenes, Handles and Messages
What is COM – Component Object Model ?
Visual Studio 2003 & [...]
Visual C++ MFC FAQ Part II
Creating & Adding Custom control to the in-built gallery of controls
Many a times we create a control and need to reuse it in number of other applications. Instead of creating the class having the same functionality or copying the already created classes we can add the created control to the in-built gallery of controls. We can then add this control to the project as and [...]
Full Story »How to display an hourglass cursor ?
Ans: Many a times our application needs quite a long time to complete a particular task. For example, we may search for a file or browse the hard disk or sort a large number of items. At such times we can display an hourglass cursor to show that the application is busy doing the task. [...]
Full Story »How to prevent dialog box from getting dismissed On pressing Esc key ?
If a dialog box is displayed and Esc key is pressed, OnCancel( ) handler gets called and the dialog gets dismissed. At times we want to take some other step when Esc key is pressed. For example, if user has selected an item from a combo box we may want that his selection should get [...]
Full Story »How can show right click properties in user-designed dialog?
If we right click on a file or a directory a pop up menu is displayed from which we can select the ‘Properties’ menu item to display the properties of the selected file/directory. How can we achieve the same in a user-designed dialog?
We will write a small program in which if user clicks a button [...]
How would you set an indicator in the caption bar indicating that the document is dirty and needs to be saved?
Ans: While working in a VC++ source editor if you observe carefully, you would see that if you make any changes in a file an indicator in the form of an asterisk ( ‘*’ ) is shown in the title bar indicating that the file is modified. If you save the file the indicator disappears. [...]
Full Story »How do I lock the splitter window so that user cannot move the divider line?
Ans: If you want to create a splitter window but do not wish to allow user to resize the panes, derive a class from CSplitterWnd. For this select Insert | New Class. Select ‘Class type’ as generic. Give the class name and enter name of base class as CSplitterWnd. Add the message handlers for [...]
Full Story »How an application remembers the last active document and automatically reopen it?
Ans: This involves two steps, first is to save the last active document when the frame window is about to close and second is to reopen it the next time application is started. Perform the first step in OnClose( ) handler of main frame class as shown below:
CString docstr = “” ;
CMDIChildWnd *pchild = [...]
Thread Synchronization : Using Mutex Objects
Download source code for this project here Thread Synchronization Using Mutex
The word mutex comes from mutually and exclusive. Mutexe is used to gain exclusive access to a resource mutually shared by two or more threads. Unlike critical sections, mutexes can be used to synchronize threads running in the same process or in different processes. There [...]
How do I associate multiple file extensions with the same document class?
Ans: In applications like Notepad and MS-Word we can open files with different file extensions. For example, in Notepad we can open a ‘.txt’ file as well as ‘.htm’ file. We can also implement this feature in our MDI application. For this create a document template object for each file extension that you want to [...]
Full Story »