X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/634903fd0431c5f09372a9ad99005cb4b2c5cd34..bfac8499858dbb52ae4e712b718dcd08e777b4c2:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 0f5ebc51ab..c9c1d5b68a 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -35,7 +35,7 @@ #include -#if !defined(__GNUWIN32__) && !defined(__SALFORDC__) +#if !defined(__GNUWIN32__) && !defined(__WXWINE__) && !defined(__SALFORDC__) #include #ifndef __MWERKS__ @@ -56,7 +56,7 @@ #include #endif -#ifdef __WIN32__ +#if defined(__WIN32__) && !defined(__WXWINE__) #include #ifndef __GNUWIN32__ @@ -299,6 +299,27 @@ class wxSleepTimer: public wxTimer static wxTimer *wxTheSleepTimer = NULL; +void wxUsleep(unsigned long milliseconds) +{ +#ifdef __WIN32__ + ::Sleep(milliseconds); +#else + if (inTimer) + return; + + wxTheSleepTimer = new wxSleepTimer; + inTimer = TRUE; + wxTheSleepTimer->Start(milliseconds); + while (inTimer) + { + if (wxTheApp->Pending()) + wxTheApp->Dispatch(); + } + delete wxTheSleepTimer; + wxTheSleepTimer = NULL; +#endif +} + void wxSleep(int nSecs) { #if 0 // WIN32 hangs app @@ -513,11 +534,11 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c #endif // wxUSE_RESOURCES // --------------------------------------------------------------------------- -// helper functiosn for showing a "busy" cursor +// helper functions for showing a "busy" cursor // --------------------------------------------------------------------------- -extern HCURSOR gs_wxBusyCursor = 0; // new, busy cursor -static HCURSOR gs_wxBusyCursorOld = 0; // old cursor +HCURSOR gs_wxBusyCursor = 0; // new, busy cursor +HCURSOR gs_wxBusyCursorOld = 0; // old cursor static int gs_wxBusyCursorCount = 0; // Set the cursor to the busy cursor for all windows @@ -537,7 +558,6 @@ void wxEndBusyCursor() wxCHECK_RET( gs_wxBusyCursorCount > 0, "no matching wxBeginBusyCursor() for wxEndBusyCursor()" ); - gs_wxBusyCursorCount--; if ( --gs_wxBusyCursorCount == 0 ) { ::SetCursor(gs_wxBusyCursorOld); @@ -625,7 +645,7 @@ char *wxGetUserHome (const wxString& user) if ((home = getenv("TMP")) != NULL || (home = getenv("TMPDIR")) != NULL || (home = getenv("TEMP")) != NULL) - return *home ? home : "\\"; + return *home ? home : (char*)"\\"; } if (Stricmp(tmp, WXSTRINGCAST user1) == 0) user1 = ""; @@ -776,6 +796,10 @@ bool wxDirExists(const wxString& dir) #endif } +// --------------------------------------------------------------------------- +// window information functions +// --------------------------------------------------------------------------- + wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd) { wxString str; @@ -786,6 +810,58 @@ wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd) return str; } +wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd) +{ + wxString str; + + int len = 256; // some starting value + + for ( ;; ) + { + // as we've #undefined GetClassName we must now manually choose the + // right function to call + int count = + + #ifndef __WIN32__ + GetClassName + #else // Win32 + #ifdef UNICODE + GetClassNameW + #else // !Unicode + #ifdef __TWIN32__ + GetClassName + #else // !Twin32 + GetClassNameA + #endif // Twin32/!Twin32 + #endif // Unicode/ANSI + #endif // Win16/32 + ((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; + } + } + + return str; +} + +WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd) +{ +#ifndef __WIN32__ + return GetWindowWord((HWND)hWnd, GWW_ID); +#else // Win32 + return GetWindowLong((HWND)hWnd, GWL_ID); +#endif // Win16/32 +} + #if 0 //------------------------------------------------------------------------ // wild character routines