X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a46a73a6776392ad1ac75ea58e53b1c3a72d9484..a98f98ac6f4422f259fc3324975156f7554adf41:/src/msw/utils.cpp?ds=sidebyside diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 2a9d0a99a4..e035e05457 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -436,29 +436,14 @@ wxChar *wxGetUserHome(const wxString& user) bool wxDirExists(const wxString& dir) { #if defined(__WIN32__) - WIN32_FIND_DATA fileInfo; + DWORD attribs = GetFileAttributes(dir); + return ((attribs != (DWORD)-1) && (attribs & FILE_ATTRIBUTE_DIRECTORY)); #else // Win16 #ifdef __BORLANDC__ struct ffblk fileInfo; #else struct find_t fileInfo; #endif -#endif // Win32/16 - -#if defined(__WIN32__) - HANDLE h = ::FindFirstFile(dir, &fileInfo); - - if ( h == INVALID_HANDLE_VALUE ) - { - wxLogLastError(wxT("FindFirstFile")); - - return FALSE; - } - - ::FindClose(h); - - return (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; -#else // Win16 // In Borland findfirst has a different argument // ordering from _dos_findfirst. But _dos_findfirst // _should_ be ok in both MS and Borland... why not? @@ -1005,10 +990,22 @@ void wxGetMousePosition( int* x, int* y ) // Return TRUE if we have a colour display bool wxColourDisplay() { - ScreenHDC dc; - int noCols = GetDeviceCaps(dc, NUMCOLORS); + // this function is called from wxDC ctor so it is called a *lot* of times + // hence we optimize it a bit but doign the check only once + // + // this should be MT safe as only the GUI thread (holding the GUI mutex) + // can call us + static int s_isColour = -1; + + if ( s_isColour == -1 ) + { + ScreenHDC dc; + int noCols = ::GetDeviceCaps(dc, NUMCOLORS); + + s_isColour = (noCols == -1) || (noCols > 2); + } - return (noCols == -1) || (noCols > 2); + return s_isColour != 0; } // Returns depth of screen