X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6756a5f8ee77cf9c77e99bd3b50857df9e41c058..e83c4d401206ff9d5568f03ade6d9713c57bdd51:/src/msw/utilsgui.cpp diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index e3c65df081..c4f2a2a112 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: msw/utilsgui.cpp -// Purpose: Various utility functions only available in GUI +// Name: src/msw/utilsgui.cpp +// Purpose: Various utility functions only available in wxMSW GUI // Author: Vadim Zeitlin // Modified by: // Created: 21.06.2003 (extracted from msw/utils.cpp) // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// License: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -38,6 +38,12 @@ // implementation // ============================================================================ +// Emit a beeeeeep +void wxBell() +{ + ::MessageBeep((UINT)-1); // default sound +} + // --------------------------------------------------------------------------- // helper functions for showing a "busy" cursor // --------------------------------------------------------------------------- @@ -101,45 +107,6 @@ bool wxCheckForInterrupt(wxWindow *wnd) return true; } -// MSW only: get user-defined resource from the .res file. -// Returns NULL or newly-allocated memory, so use delete[] to clean up. - -#ifndef __WXMICROWIN__ -wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType) -{ - HRSRC hResource = ::FindResource(wxGetInstance(), - resourceName.wx_str(), - resourceType.wx_str()); - if ( hResource == 0 ) - return NULL; - - HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource); - if ( hData == 0 ) - return NULL; - - wxChar *theText = (wxChar *)::LockResource(hData); - if ( !theText ) - return NULL; - - // Not all compilers put a zero at the end of the resource (e.g. BC++ doesn't). - // so we need to find the length of the resource. - int len = ::SizeofResource(wxGetInstance(), hResource); - wxChar *s = new wxChar[len+1]; - wxStrncpy(s,theText,len); - s[len]=0; - - // Obsolete in WIN32 -#ifndef __WIN32__ - UnlockResource(hData); -#endif - - // No need?? - // GlobalFree(hData); - - return s; -} -#endif // __WXMICROWIN__ - // ---------------------------------------------------------------------------- // get display info // ---------------------------------------------------------------------------- @@ -149,7 +116,7 @@ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourc void wxGetMousePosition( int* x, int* y ) { POINT pt; - GetCursorPos( & pt ); + wxGetCursorPosMSW( & pt ); if ( x ) *x = pt.x; if ( y ) *y = pt.y; } @@ -227,24 +194,6 @@ void wxDisplaySizeMM(int *width, int *height) #endif } -void wxClientDisplayRect(int *x, int *y, int *width, int *height) -{ -#if defined(__WXMICROWIN__) - *x = 0; *y = 0; - wxDisplaySize(width, height); -#else - // Determine the desktop dimensions minus the taskbar and any other - // special decorations... - RECT r; - - SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); - if (x) *x = r.left; - if (y) *y = r.top; - if (width) *width = r.right - r.left; - if (height) *height = r.bottom - r.top; -#endif -} - // --------------------------------------------------------------------------- // window information functions // --------------------------------------------------------------------------- @@ -302,10 +251,8 @@ int WXDLLEXPORT wxGetWindowId(WXHWND hWnd) // Metafile helpers // ---------------------------------------------------------------------------- -extern void PixelToHIMETRIC(LONG *x, LONG *y) +void PixelToHIMETRIC(LONG *x, LONG *y, HDC hdcRef) { - ScreenHDC hdcRef; - int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE), iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE), iWidthPels = GetDeviceCaps(hdcRef, HORZRES), @@ -317,10 +264,8 @@ extern void PixelToHIMETRIC(LONG *x, LONG *y) *y /= iHeightPels; } -extern void HIMETRICToPixel(LONG *x, LONG *y) +void HIMETRICToPixel(LONG *x, LONG *y, HDC hdcRef) { - ScreenHDC hdcRef; - int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE), iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE), iWidthPels = GetDeviceCaps(hdcRef, HORZRES), @@ -332,6 +277,16 @@ extern void HIMETRICToPixel(LONG *x, LONG *y) *y /= (iHeightMM * 100); } +void HIMETRICToPixel(LONG *x, LONG *y) +{ + HIMETRICToPixel(x, y, ScreenHDC()); +} + +void PixelToHIMETRIC(LONG *x, LONG *y) +{ + PixelToHIMETRIC(x, y, ScreenHDC()); +} + void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2) { #ifdef __WXWINCE__ @@ -364,11 +319,11 @@ extern bool wxEnableFileNameAutoComplete(HWND hwnd) s_initialized = true; wxLogNull nolog; - wxDynamicLibrary dll(_T("shlwapi.dll")); + wxDynamicLibrary dll(wxT("shlwapi.dll")); if ( dll.IsLoaded() ) { s_pfnSHAutoComplete = - (SHAutoComplete_t)dll.GetSymbol(_T("SHAutoComplete")); + (SHAutoComplete_t)dll.GetSymbol(wxT("SHAutoComplete")); if ( s_pfnSHAutoComplete ) { // won't be unloaded until the process termination, no big deal @@ -383,7 +338,7 @@ extern bool wxEnableFileNameAutoComplete(HWND hwnd) HRESULT hr = s_pfnSHAutoComplete(hwnd, 0x10 /* SHACF_FILESYS_ONLY */); if ( FAILED(hr) ) { - wxLogApiError(_T("SHAutoComplete"), hr); + wxLogApiError(wxT("SHAutoComplete"), hr); return false; } @@ -393,4 +348,3 @@ extern bool wxEnableFileNameAutoComplete(HWND hwnd) return false; #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS } -