diff --git a/resource/MainWindow.manifest b/resource/MainWindow.manifest
index b53405b..68b1a83 100644
--- a/resource/MainWindow.manifest
+++ b/resource/MainWindow.manifest
@@ -22,9 +22,9 @@
-
-
-
+
+
+
diff --git a/resource/MainWindow.rc b/resource/MainWindow.rc
index 1074a3a..6858bf7 100644
Binary files a/resource/MainWindow.rc and b/resource/MainWindow.rc differ
diff --git a/source/Common.AutoResource.Windows.h b/source/Common.AutoResource.Windows.h
index 989cb78..43a8e7d 100644
--- a/source/Common.AutoResource.Windows.h
+++ b/source/Common.AutoResource.Windows.h
@@ -1,3 +1,8 @@
+//----------------------------------------------------------------------------
+//
+// 2015-12-16 dwayner Split Windows specific stuff from AutoResource.h
+//
+//----------------------------------------------------------------------------
#pragma once
template <
@@ -5,7 +10,7 @@ template <
typename ResourceReleaserSignature, // function prototype of the releasing function
ResourceReleaserSignature ResourceReleaser // address of function to release object
>
-struct HandleResourceTypePolicy : public DefaultResourceTypePolicy
+struct AutoResourceHandlePolicy : public AutoResourceDefaultPolicy
{
inline static void Release(ResourceType resource) noexcept
{
@@ -19,7 +24,6 @@ struct HandleResourceTypePolicy : public DefaultResourceTypePolicy
static const bool AllowsMultipleReferences = false;
};
-
// Releasing function for WaitHandleResource to pass to use with HandleResourceTypePolicy.
inline void WaitHandleUnregister(HANDLE handle) noexcept
{
@@ -29,28 +33,40 @@ inline void WaitHandleUnregister(HANDLE handle) noexcept
}
}
+using GdiDeviceContext = AutoResource, HDC>;
+using GdiPenHandle = AutoResource, HGDIOBJ>;
+using GdiFontHandle = AutoResource, HGDIOBJ>;
+using GdiBitmapHandle = AutoResource, HGDIOBJ>;
+using GdiRegionHandle = AutoResource, HGDIOBJ>;
+using GlobalMemoryResource = AutoResource, HGLOBAL>;
+using LocalMemoryResource = AutoResource, HLOCAL>;
+using FileHandle = AutoResource, HANDLE>;
+using CstdioFileHandle = AutoResource, FILE*>;
+using ScopedMemory = AutoResource, FILE*>;
+using ModuleHandle = AutoResource, HMODULE>;
+using WindowHandle = AutoResource, HWND>;
+using MemoryViewResource = AutoResource, void*>;
+using MemorySectionResource = AutoResource, HANDLE>;
-using GdiDeviceContext = AutoResource >;
-using GdiPenHandle = AutoResource, HGDIOBJ>;
-using GdiFontHandle = AutoResource, HGDIOBJ>;
-using GdiBitmapHandle = AutoResource, HGDIOBJ>;
-using GdiRegionHandle = AutoResource, HGDIOBJ>;
-using GlobalMemoryResource = AutoResource >;
-using LocalMemoryResource = AutoResource >;
-using FileHandle = AutoResource >;
-using CstdioFileHandle = AutoResource >;
-using ScopedMemory = AutoResource >;
-using ModuleHandle = AutoResource >;
-using WindowHandle = AutoResource >;
-using MemoryViewResource = AutoResource >;
-using MemorySectionResource = AutoResource >;
-using WaitHandleResource = AutoResource>;
-
+using GdiDeviceContext = AutoResource, HDC>;
+using GdiPenHandle = AutoResource, HGDIOBJ>;
+using GdiFontHandle = AutoResource, HGDIOBJ>;
+using GdiBitmapHandle = AutoResource, HGDIOBJ>;
+using GdiRegionHandle = AutoResource, HGDIOBJ>;
+using GlobalMemoryResource = AutoResource, HGLOBAL>;
+using LocalMemoryResource = AutoResource, HLOCAL>;
+using FileHandle = AutoResource, HANDLE>;
+using CstdioFileHandle = AutoResource, FILE*>;
+using ScopedMemory = AutoResource, FILE*>;
+using ModuleHandle = AutoResource, HMODULE>;
+using WindowHandle = AutoResource, HWND>;
+using MemoryViewResource = AutoResource, void*>;
+using MemorySectionResource = AutoResource, HANDLE>;
////////////////////////////////////////
// Basic COM pointer.
-struct ComResourceTypePolicy : public DefaultResourceTypePolicy
+struct ComResourceTypePolicy : public AutoResourceDefaultPolicy
{
inline static void Acquire(_Inout_opt_ IUnknown* resource) noexcept
{
diff --git a/source/Common.AutoResource.h b/source/Common.AutoResource.h
index e8ed4bc..fb4292f 100644
--- a/source/Common.AutoResource.h
+++ b/source/Common.AutoResource.h
@@ -1,8 +1,11 @@
//+---------------------------------------------------------------------------
// Automatic resource management helper class.
//
-// History: 2007-07-30 Dwayne Robinson - Created
-// 2014-10-06 Dwayne Robinson - Changed to template typedefs
+// History: 2007-07-30 Dwayne Robinson - created
+// 2009-12-16 Dwayne Robinson - Updated to support __cdecl too (fclose)
+// 2010-07-08 Dwayne Robinson - Updated to handle ref counting policies
+// 2014-10-06 Dwayne Robinson - changed to template typedefs
+//
//----------------------------------------------------------------------------
#pragma once
@@ -17,9 +20,9 @@
// a reference to it, or zero-initialized. The resource type itself should generally be a simple
// trivially copyable thing such as a pointer or handle type.
template // type of the resource held onto
-struct DefaultResourceTypePolicy
+struct AutoResourceDefaultPolicy
{
- inline static void InitializeEmpty(_Out_ ResourceType* resource) noexcept
+ inline static void InitializeEmpty(/*out*/ ResourceType* resource) noexcept
{
// Most resources (pointers to memory, HGLOBALS, HGDIOBJ...)
// are indicated as empty by setting to 0/NULL. If a resource
@@ -63,7 +66,7 @@ struct DefaultResourceTypePolicy
// depending on the policy implementation).
template <
typename ResourceType = void*, // type of the resource held onto
- typename ResourceTypePolicy = DefaultResourceTypePolicy,
+ typename ResourceTypePolicy = AutoResourceDefaultPolicy,
typename BaseResourceType = ResourceType // type as known by the resource releaser (like HGDIOBJ vs HBITMAP)
>
class AutoResource
@@ -86,9 +89,11 @@ class AutoResource
ResourceTypePolicy::Acquire(resource_);
}
- AutoResource(Self&& other)
+ AutoResource(Self&& /*moveable*/ other)
+ : resource_(other.resource_)
{
- resource_ = other.resource_;
+ // Just reset the other resource without changing the initialization
+ // state or reference count.
ResourceTypePolicy::InitializeEmpty(Cast(&other.resource_));
}
@@ -206,7 +211,7 @@ class AutoResource
return *this;
}
- inline Self& operator=(const Self& other)
+ inline Self& operator=(Self const& other)
{
static_assert(ResourceTypePolicy::AllowsMultipleReferences, "This function is only useable on resource types that allow multiple strong references.");
Set(other.resource_);
@@ -300,7 +305,7 @@ class AutoResource
Set(resource);
}
- // there is no 'release' alias, since the C++ auto_ptr does something
+ // There is no release() function, since the C++ auto_ptr does something
// different than typically expected (detaches rather than frees).
protected:
@@ -320,7 +325,9 @@ class AutoResource
return reinterpret_cast(resource);
}
- ResourceType resource_; // could be void*, HANDLE, FILE*, GDIOBJ...
+ // Specific resource type, such as void*, HANDLE, FILE*, GDIOBJ...
+ // It is expected to be a simple data type with no copy constructors.
+ ResourceType resource_;
};
@@ -350,7 +357,7 @@ namespace std
static_assert(sizeof(int*) == sizeof(void*), "Expect all pointers have same size, such as void* and resourceType*");
template
-struct UnownedMemoryPointerPolicy : public DefaultResourceTypePolicy
+struct UnownedMemoryPointerPolicy : public AutoResourceDefaultPolicy
{
// Allow multiple references because the non-owning AutoResource does not strongly hold it anyway.
static const bool AllowsMultipleReferences = true;
@@ -367,7 +374,7 @@ using UnownedMemoryPointer = AutoResource
-struct OwnedMemoryPointerPolicy : public DefaultResourceTypePolicy
+struct OwnedMemoryPointerPolicy : public AutoResourceDefaultPolicy
{
inline static void Release(ResourceType resource) noexcept
{
diff --git a/source/DrawingCanvas.h b/source/DrawingCanvas.h
index cc2ca6b..fb7bfae 100644
--- a/source/DrawingCanvas.h
+++ b/source/DrawingCanvas.h
@@ -140,7 +140,7 @@ inline float Lerp(float first, float last, float fraction)
////////////////////
-using GdiPlusStartupAutoResource = AutoResource, ULONG_PTR>;
+using GdiPlusStartupAutoResource = AutoResource, ULONG_PTR>;
class __declspec(uuid("74868E11-F1CF-461A-AEAF-175216DFF0BA")) DrawingCanvas : public ComObject
diff --git a/source/MainWindow.ixx b/source/MainWindow.ixx
index b0d2d89..8aa00bb 100644
--- a/source/MainWindow.ixx
+++ b/source/MainWindow.ixx
@@ -493,6 +493,38 @@ INT_PTR MainWindow::InitializeMainDialog()
}
SetFocus(GetWindowFromId(hwnd_, controlIdToSetFocusTo));
+ // For Windows 7, set toolbar button labels to older font characters before Segoe UI Symbol.
+ DWORD majorWindowsVersion = LOBYTE(LOWORD(GetVersion()));
+ // GetVersion() is deprecated because it was badly designed and error-prone, but then they messed up and replaced
+ // a *slightly* error-prone function with a *much more* complicated function like VerifyVersionInfo, where far more
+ // can go wrong. Yeah, forget you, whoever poorly designed the versioning API's. We're sticking with the simpler
+ // one here.
+ if (majorWindowsVersion <= 7)
+ {
+ struct ControlIdAndText
+ {
+ int id;
+ wchar_t const* text;
+ };
+ ControlIdAndText idsAndText[] =
+ {
+ {IdcDrawableObjectListLoad, L"Load"},
+ {IdcDrawableObjectListStore, L"Save"},
+ {IdcDrawableObjectCreate, L"+"},
+ {IdcDrawableObjectDelete, L"-"},
+ {IdcDrawableObjectCreatePermutations, L"Pm"},
+ {IdcSelectFontFile, L"File"},
+ // Already okay:
+ // IdcDrawableObjectMoveUp
+ // IdcDrawableObjectMoveDown
+ // IdcSelectFontFamily
+ };
+ for (auto& idAndText : idsAndText)
+ {
+ SetWindowText(GetWindowFromId(hwnd_, idAndText.id), idAndText.text);
+ }
+ }
+
#if 0 // hack for debugging animating objects.
SetTimer(hwnd_, IdcUpdateUi + 1, 10, nullptr);
#endif
diff --git a/source/precomp.h b/source/precomp.h
index 2b55e5b..879f03b 100644
--- a/source/precomp.h
+++ b/source/precomp.h
@@ -41,6 +41,8 @@
#define NOIME
#endif
+#define BUILD_WINDOWS
+
#define _ENABLE_EXTENDED_ALIGNED_STORAGE // For the SseSizedType case, which is > max_align_t.
#define _SCL_SECURE_NO_WARNINGS // I hate doing this, but Visual Studio offers no substitute for std::uninitialized_copy.