X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a8eaaeb23796c69ea0f67cbd48fc5f667d9823d0..72bfca58d997c6f54e92aabc108c1cc18674bbee:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 3a3f03a76c..8e5fab3265 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -37,7 +37,8 @@ #include "wx/msw/private.h" // includes #include "wx/msw/missing.h" // CHARSET_HANGUL -#if defined(__GNUWIN32_OLD__) || defined(__WXWINCE__) +#if defined(__GNUWIN32_OLD__) || defined(__WXWINCE__) \ + || defined(__CYGWIN32__) // apparently we need to include winsock.h to get WSADATA and other stuff // used in wxGetFullHostName() with the old mingw32 versions #include @@ -144,7 +145,7 @@ bool wxGetHostName(wxChar *buf, int maxSize) // get full hostname (with domain name if possible) bool wxGetFullHostName(wxChar *buf, int maxSize) { -#ifndef __WXMICROWIN__ +#if !defined( __WXMICROWIN__) && wxUSE_DYNAMIC_LOADER // TODO should use GetComputerNameEx() when available // we don't want to always link with Winsock DLL as we might not use it at @@ -1012,7 +1013,7 @@ wxString wxGetOsDescription() #endif // Win32/16 } -wxToolkitInfo *wxAppTraits::GetToolkitInfo() +wxToolkitInfo& wxAppTraits::GetToolkitInfo() { // cache the version info, it's not going to change // @@ -1051,17 +1052,17 @@ wxToolkitInfo *wxAppTraits::GetToolkitInfo() case VER_PLATFORM_WIN32_CE: s_ver = wxWINDOWS_CE; break; -#endif +#endif } } } - static wxToolkitInfo info; + static wxToolkitInfo info; info.versionMajor = s_major; info.versionMinor = s_minor; info.os = s_ver; info.name = _T("wxBase"); - return &info; + return info; } // ---------------------------------------------------------------------------- @@ -1231,3 +1232,62 @@ extern long wxCharsetToCodepage(const wxChar *name) #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP +/* + Creates a hidden window with supplied window proc registering the class for + it if necesssary (i.e. the first time only). Caller is responsible for + destroying the window and unregistering the class (note that this must be + done because wxWindows may be used as a DLL and so may be loaded/unloaded + multiple times into/from the same process so we cna't rely on automatic + Windows class unregistration). + + pclassname is a pointer to a caller stored classname, which must initially be + NULL. classname is the desired wndclass classname. If function succesfully + registers the class, pclassname will be set to classname. + */ +extern "C" HWND +wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc) +{ + wxCHECK_MSG( classname && pclassname && wndproc, NULL, + _T("NULL parameter in wxCreateHiddenWindow") ); + + // register the class fi we need to first + if ( *pclassname == NULL ) + { + WNDCLASS wndclass; + wxZeroMemory(wndclass); + + wndclass.lpfnWndProc = wndproc; + wndclass.hInstance = wxGetInstance(); + wndclass.lpszClassName = classname; + + if ( !::RegisterClass(&wndclass) ) + { + wxLogLastError(wxT("RegisterClass() in wxCreateHiddenWindow")); + + return NULL; + } + + *pclassname = classname; + } + + // next create the window + HWND hwnd = ::CreateWindow + ( + *pclassname, + NULL, + 0, 0, 0, 0, + 0, + (HWND) NULL, + (HMENU)NULL, + wxGetInstance(), + (LPVOID) NULL + ); + + if ( !hwnd ) + { + wxLogLastError(wxT("CreateWindow() in wxCreateHiddenWindow")); + } + + return hwnd; +} +