9 May, 2008
The C++0x standard defines a feature called auto type determination. It is similar to the var keyword in C#. It allows you to let the compiler figure out the type of a variable. For example:
auto something = 123;
The compiler will automatically figure out that something is of type int. The above is a very simple example and in this case the developer can easily figure it out. However, with template types and template meta programming techniques it can become difficult for the developer to figure out what the type exactly is.
Consider the following loop:
for (vector<string>::const_reverse_iterator criter = vec.rbegin(); criter != vec.rend(); ++criter) {...}
With the auto feature this could be rewritten as follows:
for (auto criter = vec.rbegin(); criter != vec.rend(); ++criter) {...}
which is much easier to type.
This auto feature is also useful for variables that store a function pointer or lambda expressions because the compiler will figure out the exact type for us. Lambda expressions will be briefly described in another blog post.
2 May, 2008
I finally found some time to post a few pictures of the Microsoft MVP Global Summit 2008 in Seattle. The summit was great. There were 1753 MVPs from all over the world attending the summit. The sessions given by Microsoft product groups were very interesting. I went to all the Visual C++ sessions and it was great to hear the direction in which they are going with the product. One thing they made perfectly clear is that MFC is not dead
They are putting interesting new things in upcoming versions of MFC which allow you to create modern user interfaces for your MFC applications. One such thing is the ribon bar which is part of the MFC Feature Pack for Visual Studio 2008. Below you can see some pictures taken during the summit. Read the rest of this entry »
29 Mar, 2008
I was trying to port a screensaver from Visual Studio 2005 to Visual Studio 2008.
After loading the project in VS2008, compilation went without any problems. However, when I tried to test the screensaver on a Windows XP box I got the error message that the function ChangeWindowMessageFilter could not be found in user32.dll. The first thing I did was to open the MSDN and search for this ChangeWindowMessageFilter function. According to the documentation ChangeWindowMessageFilter is only available on Windows Vista. I obviously didn’t use that function myself otherwise I would have known about it in the first place
So I checked the libraries that I was linking to. The most obvious candidate would be the ScrnSave.lib library. I searched for it and it was linking to the version that was installed by Visual Studio 2008 in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib. To make sure I did a “dumpbin /symbols ScrnSave.Lib” on it and it was indeed using the ChangeWindowMessageFilter function.
It is pretty strange that this ScrnSave.Lib is dependent on a Vista API call. This just annoys developers that try to create a screensaver that still works on Windows XP. It should be pretty easy for the developers of ScrnSave.Lib to dynamically load the user32.dll and see if ChangeWindowMessageFilter is available.
Anyway, the easiest and quickest workaround that I’m using right now is to use the ScrnSave.Lib from the Visual Studio 2005 installation. After recompiling my screensaver with this older library it works again on Windows XP.
2 Feb, 2008
Maybe a bit late, but for those who missed the announcement, Microsoft has released a beta of the Visual C++ 2008 Feature Pack.
The Visual C++ 2008 Feature Pack extends the VC++ Libraries shipped with Visual Studio 2008.New MFC features include:
- Office Ribbon style interface
- Office 2007, Office 2003 and Office XP look and feel
- Modern Visual Studio-style docking toolbars and panes
- Fully customizable toolbars and menus
- A rich set of advanced GUI controls
- Advanced MDI tabs and groups
- And much more!
This feature pack also includes an implementation of TR1. Portions of TR1 are scheduled for adoption in the upcoming C++0x standard as the first major addition to the ISO 2003 standard C++ library. The following feature are currently supported:
- Smart pointers
- Regular expression parsing
- New containers (tuple, array, unordered set, etc)
- Sophisticated random number generators
- Polymorphic function wrappers
- Type traits
- And more!
Note: This feature pack does not include C99 compatibility or support for special math functions.
Download the beta.
16 Apr, 2007
In my previous post I explained how to save a Windows region to a file and how to load it again using MFC. Some people have problems translating MFC code to standard Win32 API code, so I wrote a followup article for CodeGuru explaining exactly the same thing but with Win32 API code instead of MFC.
The article explains in details how to save a Windows region to a file using GetRegionData and how to load and re-create this saved region with ExtCreateRegion using MFC.
There are 2 functions in the article: SaveRegion and LoadRegion. Read the rest of this entry »
16 Apr, 2007
I wrote an article for CodeGuru that explains in details how to save a Windows region to a file using CRgn::GetRegionData and how to load and re-create this saved region with CRgn::CreateFromData using MFC.
There are 2 functions in the article: SaveRegion and LoadRegion. Read the rest of this entry »