X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1aff8b0241145ab734b1efc880aeff17b5a6e955..f0492f7d97d77ec085e58d3f4a66c86508bc5f31:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index d2d584162b..8b69fd728c 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -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 @@ -775,6 +796,10 @@ bool wxDirExists(const wxString& dir) #endif } +// --------------------------------------------------------------------------- +// window information functions +// --------------------------------------------------------------------------- + wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd) { wxString str; @@ -785,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; +} + +wxWindowID WXDLLEXPORT wxGetWindowId(WXHWND hWnd) +{ +#ifndef __WIN32__ + return (wxWindowID)GetWindowWord((HWND)hWnd, GWW_ID); +#else // Win32 + return (wxWindowID)GetWindowLong((HWND)hWnd, GWL_ID); +#endif // Win16/32 +} + #if 0 //------------------------------------------------------------------------ // wild character routines