Applications build with Vista/Win7 features on does not run correctly on XP/XP x64.
Steps to reproduce:
1. #define _WIN32_WINNT=0x0600 and compile TabbedMDI demo
2. Run the executable on XP
I see a series of popups stating that:
"Failed to insert rebar band\n\n Invalid window handle."
"CWnd::CreateEx ... Failed to create window\n\n Cannot create top-level child window." - this is shown 13 times
After that a non-painting frame is shown.
This is reproducible with VS2008 and VS2010 using platform sdks for VS2008 SP1 or Windows7 and running on 32bit and 64bit XP.
I want to use Vista/Win7 features when available but also want my app to run on downlevel OSes as well.
You raise a very valid point here.
When we define _WIN32_WINNT to be 0x0600, one of the changes this brings about is that the size of the REBARBANDINFO structure changes. This causes a problem with XP and below because sizeof(REBARBANDINFO) no longer reports a size that XP expects to see. As a result attempts to use the rebar control will fail.
The fix for this is to adjust the way we determine the size of the REBARBANDINFO structure. I've added the following function to CRebar:
inline UINT CRebar::GetSizeofRBBI() const
#if defined (_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
if (GetWinVersion() < 2600)
I've committed the changes to the Win32++ working copy. You can download the updated Win32++ using SVN. If you experience difficulties with this, send me a private e-mail and I'll
forward you a copy of the Win32++ header files which include this fix.
A final word of warning. There could be other windows structures that have their sizes changed as a result of setting _WIN32_WINNT to 0x0600. If so you might need to take this into account in your code. You might find this web site of interest:
If you give me the commit number I can eaily sync with it.
You might as well get the most up to date one which is currently 824