diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2015-10-05 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:56 +0300 |
commit | 6543c280208393fa32cb0094f770d14c1cfb13b2 (patch) | |
tree | beb90f5e81e85e7957463ee5ad89cab0b3566560 /CPP/Windows | |
parent | f6444c32568553e0261ca0105083658f12be6284 (diff) |
15.0815.08
Diffstat (limited to 'CPP/Windows')
-rw-r--r-- | CPP/Windows/Control/Window2.cpp | 2 | ||||
-rw-r--r-- | CPP/Windows/ProcessUtils.h | 2 | ||||
-rw-r--r-- | CPP/Windows/PropVariant.cpp | 49 | ||||
-rw-r--r-- | CPP/Windows/PropVariant.h | 2 | ||||
-rw-r--r-- | CPP/Windows/PropVariantConv.cpp | 10 | ||||
-rw-r--r-- | CPP/Windows/Shell.cpp | 4 |
6 files changed, 41 insertions, 28 deletions
diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp index 019046cd..994d96e0 100644 --- a/CPP/Windows/Control/Window2.cpp +++ b/CPP/Windows/Control/Window2.cpp @@ -178,7 +178,7 @@ bool CWindow2::OnCommand(int /* code */, int /* itemID */, LPARAM /* lParam */, /* bool CDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(aButtonID) + switch (buttonID) { case IDOK: OnOK(); diff --git a/CPP/Windows/ProcessUtils.h b/CPP/Windows/ProcessUtils.h index c7226813..a50bb5fc 100644 --- a/CPP/Windows/ProcessUtils.h +++ b/CPP/Windows/ProcessUtils.h @@ -25,7 +25,7 @@ public: bool GetExitCodeProcess(LPDWORD lpExitCode) { return BOOLToBool(::GetExitCodeProcess(_handle, lpExitCode)); } bool Terminate(UINT exitCode) { return BOOLToBool(::TerminateProcess(_handle, exitCode)); } - #if(WINVER >= 0x0500) + #if (WINVER >= 0x0500) DWORD GetGuiResources (DWORD uiFlags) { return ::GetGuiResources(_handle, uiFlags); } #endif bool SetPriorityClass(DWORD dwPriorityClass) { return BOOLToBool(::SetPriorityClass(_handle, dwPriorityClass)); } diff --git a/CPP/Windows/PropVariant.cpp b/CPP/Windows/PropVariant.cpp index 8c7d5e19..9e36c634 100644 --- a/CPP/Windows/PropVariant.cpp +++ b/CPP/Windows/PropVariant.cpp @@ -9,23 +9,23 @@ namespace NWindows { namespace NCOM { -HRESULT PropVarEm_Alloc_Bstr(PROPVARIANT *p, unsigned numChars) throw() +BSTR AllocBstrFromAscii(const char *s) throw() { - p->bstrVal = ::SysAllocStringLen(0, numChars); - if (!p->bstrVal) + if (!s) + return NULL; + UINT len = (UINT)strlen(s); + BSTR p = ::SysAllocStringLen(NULL, len); + if (p) { - p->vt = VT_ERROR; - p->scode = E_OUTOFMEMORY; - return E_OUTOFMEMORY; + for (UINT i = 0; i <= len; i++) + p[i] = (Byte)s[i]; } - p->vt = VT_BSTR; - return S_OK; + return p; } -HRESULT PropVarEm_Set_Str(PROPVARIANT *p, const char *s) throw() +HRESULT PropVarEm_Alloc_Bstr(PROPVARIANT *p, unsigned numChars) throw() { - UINT len = (UINT)strlen(s); - p->bstrVal = ::SysAllocStringLen(0, len); + p->bstrVal = ::SysAllocStringLen(NULL, numChars); if (!p->bstrVal) { p->vt = VT_ERROR; @@ -33,12 +33,19 @@ HRESULT PropVarEm_Set_Str(PROPVARIANT *p, const char *s) throw() return E_OUTOFMEMORY; } p->vt = VT_BSTR; - BSTR dest = p->bstrVal; - for (UINT i = 0; i <= len; i++) - dest[i] = (Byte)s[i]; return S_OK; } +HRESULT PropVarEm_Set_Str(PROPVARIANT *p, const char *s) throw() +{ + p->bstrVal = AllocBstrFromAscii(s); + if (p->bstrVal) + return S_OK; + p->vt = VT_ERROR; + p->scode = E_OUTOFMEMORY; + return E_OUTOFMEMORY; +} + CPropVariant::CPropVariant(const PROPVARIANT &varSrc) { vt = VT_EMPTY; @@ -68,6 +75,7 @@ CPropVariant& CPropVariant::operator=(const CPropVariant &varSrc) InternalCopy(&varSrc); return *this; } + CPropVariant& CPropVariant::operator=(const PROPVARIANT &varSrc) { InternalCopy(&varSrc); @@ -144,20 +152,13 @@ CPropVariant& CPropVariant::operator=(const char *s) InternalClear(); vt = VT_BSTR; wReserved1 = 0; - UINT len = (UINT)strlen(s); - bstrVal = ::SysAllocStringLen(0, len); + bstrVal = AllocBstrFromAscii(s); if (!bstrVal) { throw kMemException; // vt = VT_ERROR; // scode = E_OUTOFMEMORY; } - else - { - BSTR dest = bstrVal; - for (UINT i = 0; i <= len; i++) - dest[i] = (Byte)s[i]; - } return *this; } @@ -178,7 +179,7 @@ BSTR CPropVariant::AllocBstr(unsigned numChars) InternalClear(); vt = VT_BSTR; wReserved1 = 0; - bstrVal = ::SysAllocStringLen(0, numChars); + bstrVal = ::SysAllocStringLen(NULL, numChars); if (!bstrVal) { throw kMemException; @@ -244,7 +245,7 @@ HRESULT CPropVariant::Clear() throw() HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc) throw() { ::VariantClear((tagVARIANT *)this); - switch(pSrc->vt) + switch (pSrc->vt) { case VT_UI1: case VT_I1: diff --git a/CPP/Windows/PropVariant.h b/CPP/Windows/PropVariant.h index adece3e3..3610d6a8 100644 --- a/CPP/Windows/PropVariant.h +++ b/CPP/Windows/PropVariant.h @@ -10,6 +10,8 @@ namespace NWindows { namespace NCOM { +BSTR AllocBstrFromAscii(const char *s) throw(); + HRESULT PropVariant_Clear(PROPVARIANT *p) throw(); HRESULT PropVarEm_Alloc_Bstr(PROPVARIANT *p, unsigned numChars) throw(); diff --git a/CPP/Windows/PropVariantConv.cpp b/CPP/Windows/PropVariantConv.cpp index 78f98720..fe86f936 100644 --- a/CPP/Windows/PropVariantConv.cpp +++ b/CPP/Windows/PropVariantConv.cpp @@ -37,7 +37,17 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool UINT_TO_STR_2(' ', st.wHour); UINT_TO_STR_2(':', st.wMinute); if (includeSeconds) + { UINT_TO_STR_2(':', st.wSecond); + /* + *s++ = '.'; + unsigned val = st.wMilliseconds; + s[2] = (char)('0' + val % 10); val /= 10; + s[1] = (char)('0' + val % 10); + s[0] = (char)('0' + val / 10); + s += 3; + */ + } } *s = 0; return true; diff --git a/CPP/Windows/Shell.cpp b/CPP/Windows/Shell.cpp index 0d2ac618..8e82c14a 100644 --- a/CPP/Windows/Shell.cpp +++ b/CPP/Windows/Shell.cpp @@ -177,7 +177,7 @@ bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath) int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data) { #ifndef UNDER_CE - switch(uMsg) + switch (uMsg) { case BFFM_INITIALIZED: { @@ -275,7 +275,7 @@ bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath) int CALLBACK BrowseCallbackProc2(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data) { - switch(uMsg) + switch (uMsg) { case BFFM_INITIALIZED: { |