From d430edf45f6d98cdb197f853e32cb67b59568f01 Mon Sep 17 00:00:00 2001 From: koldo Date: Mon, 5 Dec 2016 09:18:57 +0000 Subject: [PATCH] *SysInfo: Some updates after U++ changes and luoganda report git-svn-id: svn://ultimatepp.org/upp/trunk@10515 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/SysInfo/Battery.cpp | 4 +-- bazaar/SysInfo/CPUSpeed.cpp | 4 +-- bazaar/SysInfo/MouseKey.cpp | 4 +-- bazaar/SysInfo/OS.cpp | 4 +-- bazaar/SysInfo/ScreenGrab.cpp | 50 ++++++++++++++++++++++------------- bazaar/SysInfo/SysInfo.cpp | 20 +++++++------- bazaar/SysInfo/SysInfo.h | 4 +-- 7 files changed, 53 insertions(+), 37 deletions(-) diff --git a/bazaar/SysInfo/Battery.cpp b/bazaar/SysInfo/Battery.cpp index cf01b0449..5a9012a5e 100644 --- a/bazaar/SysInfo/Battery.cpp +++ b/bazaar/SysInfo/Battery.cpp @@ -1,6 +1,6 @@ #include "SysInfo_in.h" -NAMESPACE_UPP +using namespace Upp; #ifdef PLATFORM_POSIX bool GetBatteryStatus(bool &discharging, int &percentage, int &remainingMin) @@ -170,4 +170,4 @@ bool CloseCDTray(String drive) #endif -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/CPUSpeed.cpp b/bazaar/SysInfo/CPUSpeed.cpp index d68ab2a21..b5f458fc0 100644 --- a/bazaar/SysInfo/CPUSpeed.cpp +++ b/bazaar/SysInfo/CPUSpeed.cpp @@ -1,6 +1,6 @@ #include "SysInfo.h" -NAMESPACE_UPP +using namespace Upp; #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) uint64 start, end; @@ -63,4 +63,4 @@ int GetCpuSpeed() } #endif -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/MouseKey.cpp b/bazaar/SysInfo/MouseKey.cpp index 79f0e4a7a..462ae4b03 100644 --- a/bazaar/SysInfo/MouseKey.cpp +++ b/bazaar/SysInfo/MouseKey.cpp @@ -1,6 +1,6 @@ #include "SysInfo_in.h" -NAMESPACE_UPP +using namespace Upp; struct KeyCodes { String key; @@ -532,4 +532,4 @@ void Keyb_SendKeys(String text, long finalDelay, long delayBetweenKeys) #endif -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/OS.cpp b/bazaar/SysInfo/OS.cpp index 68597b36a..a82009f2d 100644 --- a/bazaar/SysInfo/OS.cpp +++ b/bazaar/SysInfo/OS.cpp @@ -1,6 +1,6 @@ #include "SysInfo_in.h" -NAMESPACE_UPP +using namespace Upp; #if defined(PLATFORM_WIN32) || defined (PLATFORM_WIN64) @@ -674,4 +674,4 @@ bool GetOsInfo(String &kernel, String &kerVersion, String &kerArchitecture, Stri #endif -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/ScreenGrab.cpp b/bazaar/SysInfo/ScreenGrab.cpp index 0165ead98..2dc400f8a 100644 --- a/bazaar/SysInfo/ScreenGrab.cpp +++ b/bazaar/SysInfo/ScreenGrab.cpp @@ -4,7 +4,7 @@ #include #include -NAMESPACE_UPP +using namespace Upp; bool Window_SaveCapture(int64 windowId, String fileName, int left, int top, int width, int height) @@ -78,33 +78,47 @@ Image Window_SaveCapture(int64 windowId, int left, int top, int width, int heigh ImageBuffer b; if ((hDC = GetDC(0)) == NULL) - goto end; - if ((memDC = CreateCompatibleDC(hDC)) == NULL) - goto end; - if ((hb = CreateCompatibleBitmap(hDC, width, height)) == NULL) - goto end; - if ((oldBM = (HBITMAP)SelectObject(memDC, hb)) == NULL) - goto end; - if (!BitBlt(memDC, 0, 0, width, height , hDC, left, top, SRCCOPY)) - goto end; + return Null; + if ((memDC = CreateCompatibleDC(hDC)) == NULL) { + ReleaseDC(0, hDC); + return Null; + } + if ((hb = CreateCompatibleBitmap(hDC, width, height)) == NULL) { + DeleteDC(memDC); + ReleaseDC(0, hDC); + return Null; + } + if ((oldBM = (HBITMAP)SelectObject(memDC, hb)) == NULL) { + DeleteObject(hb); + DeleteDC(memDC); + ReleaseDC(0, hDC); + return Null; + } + if (!BitBlt(memDC, 0, 0, width, height , hDC, left, top, SRCCOPY)) { + DeleteObject(hb); + DeleteDC(memDC); + ReleaseDC(0, hDC); + return Null; + } BITMAPINFO bmpInfo; ZeroMemory(&bmpInfo, sizeof(BITMAPINFO)); bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - if (!GetDIBits(hDC, hb, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS)) - goto end; + if (!GetDIBits(hDC, hb, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS)) { + DeleteObject(hb); + DeleteDC(memDC); + ReleaseDC(0, hDC); + return Null; + } if(bmpInfo.bmiHeader.biSizeImage <= 0) bmpInfo.bmiHeader.biSizeImage = bmpInfo.bmiHeader.biWidth*labs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8; bmpInfo.bmiHeader.biCompression = BI_RGB; bmpInfo.bmiHeader.biHeight = -height; b.Create(width, height); - if (!GetDIBits(hDC, hb, 0, height, ~b, (BITMAPINFO *)&bmpInfo.bmiHeader, DIB_RGB_COLORS)) - goto end; + if (GetDIBits(hDC, hb, 0, height, ~b, (BITMAPINFO *)&bmpInfo.bmiHeader, DIB_RGB_COLORS)) + img = b; - img = b; - -end: SelectObject(hDC, oldBM); DeleteObject(hb); DeleteDC(memDC); @@ -615,4 +629,4 @@ Image Snap_Window(int64 handle) return Window_SaveCapture(handle); } -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/SysInfo.cpp b/bazaar/SysInfo/SysInfo.cpp index a3decbed2..3f95c3bdc 100644 --- a/bazaar/SysInfo/SysInfo.cpp +++ b/bazaar/SysInfo/SysInfo.cpp @@ -11,7 +11,7 @@ #endif #endif -NAMESPACE_UPP +using namespace Upp; #define TFILE #include @@ -24,10 +24,12 @@ NAMESPACE_UPP // Hardware Info #if defined(PLATFORM_WIN32) -#ifdef COMPILER_MINGW -REFCLSID CLSID_WbemAdministrativeLocator = +#ifdef COMPILER_MINGW +REFCLSID ___CLSID_WbemAdministrativeLocator = { 0xcb8555cc, 0x9128, 0x11d1, {0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}}; -#endif +#else +#define ___CLSID_WbemAdministrativeLocator CLSID_WbemAdministrativeLocator +#endif bool GetWMIInfo(String system, Array &data, Array *ret[], String nameSpace = "root\\cimv2") { HRESULT hRes; @@ -43,7 +45,7 @@ bool GetWMIInfo(String system, Array &data, Array *ret[], Strin return false; } IWbemLocator* pIWbemLocator = NULL; - if (CoCreateInstance(CLSID_WbemAdministrativeLocator, NULL, + if (CoCreateInstance(___CLSID_WbemAdministrativeLocator, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown, (void **)&pIWbemLocator) != S_OK) { CoUninitialize(); return false; @@ -1874,17 +1876,17 @@ bool Window_SetRect(int64 windowId, long left, long top, long right, long bottom void Window_Bottom(int64 windowId) { - SetWindowPos(reinterpret_cast(windowId), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE || SWP_NOSIZE || SWP_SHOWWINDOW); + SetWindowPos(reinterpret_cast(windowId), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } void Window_Top(int64 windowId) { - SetWindowPos(reinterpret_cast(windowId), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE || SWP_NOSIZE || SWP_SHOWWINDOW); + SetWindowPos(reinterpret_cast(windowId), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } void Window_TopMost(int64 windowId) { - SetWindowPos(reinterpret_cast(windowId), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE || SWP_NOSIZE || SWP_SHOWWINDOW); + SetWindowPos(reinterpret_cast(windowId), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } #endif @@ -2220,4 +2222,4 @@ bool IsPortFree(int port) { return ret; } -END_UPP_NAMESPACE \ No newline at end of file +//END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/SysInfo/SysInfo.h b/bazaar/SysInfo/SysInfo.h index 0de4573e7..697706d3c 100644 --- a/bazaar/SysInfo/SysInfo.h +++ b/bazaar/SysInfo/SysInfo.h @@ -3,7 +3,7 @@ #include "Functions4U/Functions4U.h" -NAMESPACE_UPP +using namespace Upp; ///////////////////////////////////////////////////////////////////// // Processor Info @@ -223,7 +223,7 @@ struct SystemOverview : DeepCopyOption { void Serialize(Stream &stream); }; -END_UPP_NAMESPACE +//END_UPP_NAMESPACE #endif