+void wxClientDisplayRect(int *x, int *y, int *width, int *height)
+{
+#if defined(__WIN16__) || defined(__WXMICROWIN__)
+ *x = 0; *y = 0;
+ wxDisplaySize(width, height);
+#else
+ // Determine the desktop dimensions minus the taskbar and any other
+ // special decorations...
+ RECT r;
+
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
+ if (x) *x = r.left;
+ if (y) *y = r.top;
+ if (width) *width = r.right - r.left;
+ if (height) *height = r.bottom - r.top;
+#endif
+}
+
+// ---------------------------------------------------------------------------
+// window information functions
+// ---------------------------------------------------------------------------
+
+wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
+{
+ wxString str;
+
+ if ( hWnd )
+ {
+ int len = GetWindowTextLength((HWND)hWnd) + 1;
+ ::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
+ str.UngetWriteBuf();
+ }
+
+ return str;
+}
+
+wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
+{
+ wxString str;
+
+ // MICROWIN_TODO
+#ifndef __WXMICROWIN__
+ if ( hWnd )
+ {
+ int len = 256; // some starting value
+
+ for ( ;; )
+ {
+ int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
+
+ str.UngetWriteBuf();
+ if ( count == len )
+ {
+ // the class name might have been truncated, retry with larger
+ // buffer
+ len *= 2;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+#endif // !__WXMICROWIN__
+
+ return str;
+}
+
+WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
+{
+#ifndef __WIN32__
+ return (WXWORD)GetWindowWord((HWND)hWnd, GWW_ID);
+#else // Win32
+ return (WXWORD)GetWindowLong((HWND)hWnd, GWL_ID);
+#endif // Win16/32
+}
+
+// ----------------------------------------------------------------------------
+// Metafile helpers
+// ----------------------------------------------------------------------------
+
+extern void PixelToHIMETRIC(LONG *x, LONG *y)
+{
+ ScreenHDC hdcRef;
+
+ int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
+ iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
+ iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
+ iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
+
+ *x *= (iWidthMM * 100);
+ *x /= iWidthPels;
+ *y *= (iHeightMM * 100);
+ *y /= iHeightPels;
+}
+
+extern void HIMETRICToPixel(LONG *x, LONG *y)
+{
+ ScreenHDC hdcRef;
+
+ int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
+ iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
+ iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
+ iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
+
+ *x *= iWidthPels;
+ *x /= (iWidthMM * 100);
+ *y *= iHeightPels;
+ *y /= (iHeightMM * 100);
+}
+
+#endif // wxUSE_GUI
+
+#ifdef __WXMICROWIN__
+int wxGetOsVersion(int *majorVsn, int *minorVsn)
+{
+ // MICROWIN_TODO
+ if (majorVsn) *majorVsn = 0;
+ if (minorVsn) *minorVsn = 0;
+ return wxUNIX;
+}
+#endif // __WXMICROWIN__
+
+// ----------------------------------------------------------------------------
+// Win32 codepage conversion functions
+// ----------------------------------------------------------------------------
+
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
+
+// wxGetNativeFontEncoding() doesn't exist neither in wxBase nor in wxUniv
+#if wxUSE_GUI && !defined(__WXUNIVERSAL__)
+
+#include "wx/fontmap.h"
+
+// VZ: the new version of wxCharsetToCodepage() is more politically correct
+// and should work on other Windows versions as well but the old version is
+// still needed for !wxUSE_FONTMAP || !wxUSE_GUI case
+
+extern long wxEncodingToCodepage(wxFontEncoding encoding)
+{
+ // translate encoding into the Windows CHARSET
+ wxNativeEncodingInfo natveEncInfo;
+ if ( !wxGetNativeFontEncoding(encoding, &natveEncInfo) )
+ return -1;
+
+ // translate CHARSET to code page
+ CHARSETINFO csetInfo;
+ if ( !::TranslateCharsetInfo((DWORD *)(DWORD)natveEncInfo.charset,
+ &csetInfo,
+ TCI_SRCCHARSET) )
+ {
+ wxLogLastError(_T("TranslateCharsetInfo(TCI_SRCCHARSET)"));
+
+ return -1;
+ }
+
+ return csetInfo.ciACP;
+}
+
+#if wxUSE_FONTMAP
+
+extern long wxCharsetToCodepage(const wxChar *name)
+{
+ // first get the font encoding for this charset
+ if ( !name )
+ return -1;
+
+ wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(name, FALSE);
+ if ( enc == wxFONTENCODING_SYSTEM )
+ return -1;
+
+ // the use the helper function
+ return wxEncodingToCodepage(enc);
+}
+
+#endif // wxUSE_FONTMAP
+
+#endif // wxUSE_GUI
+
+// include old wxCharsetToCodepage() by OK if needed
+#if !wxUSE_GUI || !wxUSE_FONTMAP
+
+#include "wx/msw/registry.h"
+
+// this should work if Internet Exploiter is installed
+extern long wxCharsetToCodepage(const wxChar *name)
+{
+ if (!name)
+ return GetACP();
+
+ long CP=-1;
+
+ wxString cn(name);
+ do {
+ wxString path(wxT("MIME\\Database\\Charset\\"));
+ path += cn;
+ wxRegKey key(wxRegKey::HKCR, path);
+
+ if (!key.Exists()) break;
+
+ // two cases: either there's an AliasForCharset string,
+ // or there are Codepage and InternetEncoding dwords.
+ // The InternetEncoding gives us the actual encoding,
+ // the Codepage just says which Windows character set to
+ // use when displaying the data.
+ if (key.HasValue(wxT("InternetEncoding")) &&
+ key.QueryValue(wxT("InternetEncoding"), &CP)) break;
+
+ // no encoding, see if it's an alias
+ if (!key.HasValue(wxT("AliasForCharset")) ||
+ !key.QueryValue(wxT("AliasForCharset"), cn)) break;
+ } while (1);
+
+ return CP;
+}
+
+#endif // !wxUSE_GUI || !wxUSE_FONTMAP
+
+#endif // Win32
+