// Created: 21.06.2003 (extracted from msw/utils.cpp)
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// License: wxWindows license
+// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
#ifndef WX_PRECOMP
#include "wx/cursor.h"
+ #include "wx/window.h"
#include "wx/utils.h"
#endif //WX_PRECOMP
+#include "wx/dynlib.h"
+
#include "wx/msw/private.h" // includes <windows.h>
// ============================================================================
#if wxUSE_RESOURCES
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
{
- if (file != wxT(""))
+ if (file != wxEmptyString)
// Don't know what the correct cast should be, but it doesn't
// compile in BC++/16-bit without this cast.
#if !defined(__WIN32__)
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{
static const wxChar defunkt[] = wxT("$$default");
- if (file != wxT(""))
+
+ wxChar buf[1024];
+ if (file != wxEmptyString)
{
- int n = GetPrivateProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
- (LPTSTR)wxBuffer, 1000, (LPCTSTR)WXSTRINGCAST file);
- if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
- return FALSE;
+ int n = GetPrivateProfileString(section, entry, defunkt,
+ buf, WXSIZEOF(buf), file);
+ if (n == 0 || wxStrcmp(buf, defunkt) == 0)
+ return false;
}
else
{
- int n = GetProfileString((LPCTSTR)WXSTRINGCAST section, (LPCTSTR)WXSTRINGCAST entry, (LPCTSTR)defunkt,
- (LPTSTR)wxBuffer, 1000);
- if (n == 0 || wxStrcmp(wxBuffer, defunkt) == 0)
- return FALSE;
+ int n = GetProfileString(section, entry, defunkt, buf, WXSIZEOF(buf));
+ if (n == 0 || wxStrcmp(buf, defunkt) == 0)
+ return false;
}
if (*value) delete[] (*value);
- *value = copystring(wxBuffer);
- return TRUE;
+ *value = wxStrcpy(new wxChar[wxStrlen(buf) + 1], buf);
+ return true;
}
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
{
*value = (float)wxStrtod(s, NULL);
delete[] s;
- return TRUE;
+ return true;
}
- else return FALSE;
+ else return false;
}
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
{
*value = wxStrtol(s, NULL, 10);
delete[] s;
- return TRUE;
+ return true;
}
- else return FALSE;
+ else return false;
}
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
{
*value = (int)wxStrtol(s, NULL, 10);
delete[] s;
- return TRUE;
+ return true;
}
- else return FALSE;
+ else return false;
}
#endif // wxUSE_RESOURCES
}
// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
+void wxBeginBusyCursor(const wxCursor *cursor)
{
if ( gs_wxBusyCursorCount++ == 0 )
{
}
}
-// TRUE if we're between the above two calls
+// true if we're between the above two calls
bool wxIsBusy()
{
return gs_wxBusyCursorCount > 0;
// in long calculations.
bool wxCheckForInterrupt(wxWindow *wnd)
{
- wxCHECK( wnd, FALSE );
+ wxCHECK( wnd, false );
MSG msg;
while ( ::PeekMessage(&msg, GetHwndOf(wnd), 0, 0, PM_REMOVE) )
::DispatchMessage(&msg);
}
- return TRUE;
+ return true;
}
// MSW only: get user-defined resource from the .res file.
GetCursorPos( & pt );
if ( x ) *x = pt.x;
if ( y ) *y = pt.y;
-};
+}
-// Return TRUE if we have a colour display
+// Return true if we have a colour display
bool wxColourDisplay()
{
#ifdef __WXMICROWIN__
// MICROWIN_TODO
- return TRUE;
+ return true;
#else
// 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
+ // hence we optimize it a bit but doing the check only once
//
// this should be MT safe as only the GUI thread (holding the GUI mutex)
// can call us
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
{
-#if defined(__WIN16__) || defined(__WXMICROWIN__)
+#if defined(__WXMICROWIN__)
*x = 0; *y = 0;
wxDisplaySize(width, height);
#else
if ( hWnd )
{
int len = GetWindowTextLength((HWND)hWnd) + 1;
- ::GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
- str.UngetWriteBuf();
+ ::GetWindowText((HWND)hWnd, wxStringBuffer(str, len), len);
}
return str;
for ( ;; )
{
- int count = ::GetClassName((HWND)hWnd, str.GetWriteBuf(len), len);
+ int count = ::GetClassName((HWND)hWnd, wxStringBuffer(str, len), len);
- str.UngetWriteBuf();
if ( count == len )
{
// the class name might have been truncated, retry with larger
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
}
// ----------------------------------------------------------------------------
*y /= (iHeightMM * 100);
}
+void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2)
+{
+#ifdef __WXWINCE__
+ POINT points[2];
+ points[0].x = x1;
+ points[0].y = y1;
+ points[1].x = x2;
+ points[1].y = y2;
+ Polyline(hdc, points, 2);
+#else
+ MoveToEx(hdc, x1, y1, NULL); LineTo((HDC) hdc, x2, y2);
+#endif
+}
+
+
+// ----------------------------------------------------------------------------
+// Shell API wrappers
+// ----------------------------------------------------------------------------
+
+extern bool wxEnableFileNameAutoComplete(HWND hwnd)
+{
+#if wxUSE_DYNLIB_CLASS
+ typedef HRESULT (WINAPI *SHAutoComplete_t)(HWND, DWORD);
+
+ static SHAutoComplete_t s_pfnSHAutoComplete = NULL;
+ static bool s_initialized = false;
+
+ if ( !s_initialized )
+ {
+ s_initialized = true;
+
+ wxLogNull nolog;
+ wxDynamicLibrary dll(_T("shlwapi.dll"));
+ if ( dll.IsLoaded() )
+ {
+ s_pfnSHAutoComplete =
+ (SHAutoComplete_t)dll.GetSymbol(_T("SHAutoComplete"));
+ if ( s_pfnSHAutoComplete )
+ {
+ // won't be unloaded until the process termination, no big deal
+ dll.Detach();
+ }
+ }
+ }
+
+ if ( !s_pfnSHAutoComplete )
+ return false;
+
+ HRESULT hr = s_pfnSHAutoComplete(hwnd, 0x10 /* SHACF_FILESYS_ONLY */);
+ if ( FAILED(hr) )
+ {
+ wxLogApiError(_T("SHAutoComplete"), hr);
+ return false;
+ }
+
+ return true;
+#else
+ wxUnusedVar(hwnd);
+ return false;
+#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
+}