-#ifdef __WXWINCE__
- // this doesn't make any sense knowing that windows.h includes all these
- // headers anyhow, but the fact remains that when building using eVC 4 the
- // functions and constants from these headers are not defined unless we
- // explicitly include them ourselves -- how is it possible is beyond me...
- #include <winbase.h>
- #include <wingdi.h>
- #include <winuser.h>
+// before including windows.h, define version macros at (currently) maximal
+// values because we do all our checks at run-time anyhow
+#ifndef WINVER
+ // the only exception to the above is MSVC 6 which has a time bomb in its
+ // headers: they warn against using them with WINVER >= 0x0500 as they
+ // contain only part of the declarations and they're not always correct, so
+ // don't define WINVER for it at all as this allows everything to work as
+ // expected both with standard VC6 headers (which define WINVER as 0x0400
+ // by default) and headers from a newer SDK (which may define it as 0x0500)
+ #if !defined(__VISUALC__) || (__VISUALC__ >= 1300)
+ #define WINVER 0x0600
+ #endif
+#endif
+
+#ifndef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0600
+#endif
+
+/* Deal with clash with __WINDOWS__ include guard */
+#if defined(__WXWINCE__) && defined(__WINDOWS__)
+#undef __WINDOWS__
+#endif