New Controls for MFC
(Page 1 of 5 )
Looking for information on the new controls in the MFC Feature Pack? Don't expect to find it in a book. Keep reading this article, on the other hand, and you'll find all the details you could want.
Nowadays, there are a couple of fast evolving markets. IT is certainly one of them. Documenting all the modifications and extending them is hard work. There are countless hours of intensive research, writing, probing and rewriting of entire paragraphs for a technical book to appear. By the time you manage to write a high quality book, there is a high chance that technology you describe it is already outdated.
Therefore, I am not surprised that last time I searched for a book/article describing the new controls introduced by the MFC Feature Pack, I found nothing. This article will try to fill this lack. I will describe each control in depth, in code and images. To demonstrate it visually I will use the following sample you can download from the MSDN: New Controls.
Although I find the online documentation hard to decipher, what is truly interesting is that this application is well written. You can split up the controls into six main categories: Buttons, Color Controls, Masked Edit, List Controls, Shell Controls and other controls. The application will resemble this list.
We will integrate all the controls into a single dialog. To avoid a big mess, we will use property pages. There exists a class for this in the feature pack as well, named CMFCPropertyPage. This supports the display of pop-up menus on a property. This is just what we need. To use them, we need to complete a couple of steps.
First, start up the resource manager and add a new dialog. Populate it with various controls that will host the new ones. Obviously, you will not find the corresponding items in the toolbox to do so. However, use items that behave similarly. For instance, a color picker acts like a button: push it in a place and you generate an action.
Then use the add class option for the dialog. Within this, you can replace the button's definition -- for example, with a color picker, and so on. Replace the CDHtmlDialog to CMFCPropertyPage. Now we can override/extend two main functions.
The application calls the OnInitDialog when it creates the property page. The second call is to the DoDataExchange, which will help us to synchronize the data inside the property page and the ones in the memory. Use the first to initialize the objects and define their behavior. If you created the right type of object, you can leave the second function as it is. It will synchronize any specific change to the corresponding function.
Next: Create a property sheet inside a dialog >>
More .NET Articles
More By Gabor Bernat