Skip to content

Commit 1dcfa3e

Browse files
committed
Fix Windows 7 button missing glyphs
1 parent 96479f9 commit 1dcfa3e

File tree

7 files changed

+92
-35
lines changed

7 files changed

+92
-35
lines changed

resource/MainWindow.manifest

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<!--This Id value indicates the application supports Windows 8/Server 2012 functionality-->
2323
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
2424
<!-- This Id value indicates the application supports Windows 8.1 Blue/Server 2012 R2 functionality-->
25-
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
26-
<!-- This Id value indicates the application supports Windows Threshold functionality-->
27-
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
25+
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
26+
<!-- This Id value indicates the application supports Windows 10 (Threshold) functionality-->
27+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
2828
</application>
2929
</compatibility>
3030
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">

resource/MainWindow.rc

4 Bytes
Binary file not shown.

source/Common.AutoResource.Windows.h

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
//----------------------------------------------------------------------------
2+
//
3+
// 2015-12-16 dwayner Split Windows specific stuff from AutoResource.h
4+
//
5+
//----------------------------------------------------------------------------
16
#pragma once
27

38
template <
49
typename ResourceType, // underlying type of the resource held onto (e.g. HGDIOBJ instead of HFONT)
510
typename ResourceReleaserSignature, // function prototype of the releasing function
611
ResourceReleaserSignature ResourceReleaser // address of function to release object
712
>
8-
struct HandleResourceTypePolicy : public DefaultResourceTypePolicy<ResourceType>
13+
struct AutoResourceHandlePolicy : public AutoResourceDefaultPolicy<ResourceType>
914
{
1015
inline static void Release(ResourceType resource) noexcept
1116
{
@@ -19,7 +24,6 @@ struct HandleResourceTypePolicy : public DefaultResourceTypePolicy<ResourceType>
1924
static const bool AllowsMultipleReferences = false;
2025
};
2126

22-
2327
// Releasing function for WaitHandleResource to pass to use with HandleResourceTypePolicy.
2428
inline void WaitHandleUnregister(HANDLE handle) noexcept
2529
{
@@ -29,28 +33,40 @@ inline void WaitHandleUnregister(HANDLE handle) noexcept
2933
}
3034
}
3135

36+
using GdiDeviceContext = AutoResource<HDC, AutoResourceHandlePolicy<HDC, BOOL (WINAPI*)(HDC), &DeleteDC>, HDC>;
37+
using GdiPenHandle = AutoResource<HPEN, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
38+
using GdiFontHandle = AutoResource<HFONT, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
39+
using GdiBitmapHandle = AutoResource<HBITMAP, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
40+
using GdiRegionHandle = AutoResource<HRGN, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
41+
using GlobalMemoryResource = AutoResource<HGLOBAL, AutoResourceHandlePolicy<HGLOBAL, HGLOBAL (WINAPI*)(HGLOBAL), &GlobalFree>, HGLOBAL>;
42+
using LocalMemoryResource = AutoResource<HLOCAL, AutoResourceHandlePolicy<HLOCAL, HLOCAL (WINAPI*)(HLOCAL), &LocalFree>, HLOCAL>;
43+
using FileHandle = AutoResource<HANDLE, AutoResourceHandlePolicy<HANDLE, BOOL (WINAPI*)(HANDLE), &CloseHandle>, HANDLE>;
44+
using CstdioFileHandle = AutoResource<FILE*, AutoResourceHandlePolicy<FILE*, int (__cdecl *)(FILE*), &fclose>, FILE*>;
45+
using ScopedMemory = AutoResource<FILE*, AutoResourceHandlePolicy<void*, void (__cdecl *)(void*), &free>, FILE*>;
46+
using ModuleHandle = AutoResource<HMODULE, AutoResourceHandlePolicy<HMODULE, BOOL (WINAPI*)(HMODULE), &FreeLibrary>, HMODULE>;
47+
using WindowHandle = AutoResource<HWND, AutoResourceHandlePolicy<HWND, BOOL (WINAPI*)(HWND), &DestroyWindow>, HWND>;
48+
using MemoryViewResource = AutoResource<void*, AutoResourceHandlePolicy<void*, BOOL (WINAPI*)(void const*), &UnmapViewOfFile>, void*>;
49+
using MemorySectionResource = AutoResource<HANDLE, AutoResourceHandlePolicy<HANDLE, BOOL (WINAPI*)(HANDLE), &CloseHandle>, HANDLE>;
3250

33-
using GdiDeviceContext = AutoResource<HDC, HandleResourceTypePolicy<HDC, BOOL(WINAPI*)(HDC), &DeleteDC> >;
34-
using GdiPenHandle = AutoResource<HPEN, HandleResourceTypePolicy<HGDIOBJ, BOOL(WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
35-
using GdiFontHandle = AutoResource<HFONT, HandleResourceTypePolicy<HGDIOBJ, BOOL(WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
36-
using GdiBitmapHandle = AutoResource<HBITMAP, HandleResourceTypePolicy<HGDIOBJ, BOOL(WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
37-
using GdiRegionHandle = AutoResource<HRGN, HandleResourceTypePolicy<HGDIOBJ, BOOL(WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
38-
using GlobalMemoryResource = AutoResource<HGLOBAL, HandleResourceTypePolicy<HGLOBAL, HGLOBAL(WINAPI*)(HGLOBAL), &GlobalFree> >;
39-
using LocalMemoryResource = AutoResource<HLOCAL, HandleResourceTypePolicy<HLOCAL, HLOCAL(WINAPI*)(HLOCAL), &LocalFree> >;
40-
using FileHandle = AutoResource<HANDLE, HandleResourceTypePolicy<HANDLE, BOOL(WINAPI*)(HANDLE), &CloseHandle> >;
41-
using CstdioFileHandle = AutoResource<FILE*, HandleResourceTypePolicy<FILE*, int(__cdecl *)(FILE*), &fclose> >;
42-
using ScopedMemory = AutoResource<void*, HandleResourceTypePolicy<void*, void(__cdecl *)(void*), &free> >;
43-
using ModuleHandle = AutoResource<HMODULE, HandleResourceTypePolicy<HMODULE, BOOL(WINAPI*)(HMODULE), &FreeLibrary> >;
44-
using WindowHandle = AutoResource<HWND, HandleResourceTypePolicy<HWND, BOOL(WINAPI*)(HWND), &DestroyWindow> >;
45-
using MemoryViewResource = AutoResource<void*, HandleResourceTypePolicy<void*, BOOL(WINAPI*)(void const*), &UnmapViewOfFile> >;
46-
using MemorySectionResource = AutoResource<HANDLE, HandleResourceTypePolicy<HANDLE, BOOL(WINAPI*)(HANDLE), &CloseHandle> >;
47-
using WaitHandleResource = AutoResource<HANDLE, HandleResourceTypePolicy<HANDLE, void(*)(HANDLE), &WaitHandleUnregister>>;
48-
51+
using GdiDeviceContext = AutoResource<HDC, AutoResourceHandlePolicy<HDC, BOOL (WINAPI*)(HDC), &DeleteDC>, HDC>;
52+
using GdiPenHandle = AutoResource<HPEN, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
53+
using GdiFontHandle = AutoResource<HFONT, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
54+
using GdiBitmapHandle = AutoResource<HBITMAP, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
55+
using GdiRegionHandle = AutoResource<HRGN, AutoResourceHandlePolicy<HGDIOBJ, BOOL (WINAPI*)(HGDIOBJ), &DeleteObject>, HGDIOBJ>;
56+
using GlobalMemoryResource = AutoResource<HGLOBAL, AutoResourceHandlePolicy<HGLOBAL, HGLOBAL (WINAPI*)(HGLOBAL), &GlobalFree>, HGLOBAL>;
57+
using LocalMemoryResource = AutoResource<HLOCAL, AutoResourceHandlePolicy<HLOCAL, HLOCAL (WINAPI*)(HLOCAL), &LocalFree>, HLOCAL>;
58+
using FileHandle = AutoResource<HANDLE, AutoResourceHandlePolicy<HANDLE, BOOL (WINAPI*)(HANDLE), &CloseHandle>, HANDLE>;
59+
using CstdioFileHandle = AutoResource<FILE*, AutoResourceHandlePolicy<FILE*, int (__cdecl *)(FILE*), &fclose>, FILE*>;
60+
using ScopedMemory = AutoResource<FILE*, AutoResourceHandlePolicy<void*, void (__cdecl *)(void*), &free>, FILE*>;
61+
using ModuleHandle = AutoResource<HMODULE, AutoResourceHandlePolicy<HMODULE, BOOL (WINAPI*)(HMODULE), &FreeLibrary>, HMODULE>;
62+
using WindowHandle = AutoResource<HWND, AutoResourceHandlePolicy<HWND, BOOL (WINAPI*)(HWND), &DestroyWindow>, HWND>;
63+
using MemoryViewResource = AutoResource<void*, AutoResourceHandlePolicy<void*, BOOL (WINAPI*)(void const*), &UnmapViewOfFile>, void*>;
64+
using MemorySectionResource = AutoResource<HANDLE, AutoResourceHandlePolicy<HANDLE, BOOL (WINAPI*)(HANDLE), &CloseHandle>, HANDLE>;
4965

5066
////////////////////////////////////////
5167
// Basic COM pointer.
5268

53-
struct ComResourceTypePolicy : public DefaultResourceTypePolicy<IUnknown*>
69+
struct ComResourceTypePolicy : public AutoResourceDefaultPolicy<IUnknown*>
5470
{
5571
inline static void Acquire(_Inout_opt_ IUnknown* resource) noexcept
5672
{

source/Common.AutoResource.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
//+---------------------------------------------------------------------------
22
// Automatic resource management helper class.
33
//
4-
// History: 2007-07-30 Dwayne Robinson - Created
5-
// 2014-10-06 Dwayne Robinson - Changed to template typedefs
4+
// History: 2007-07-30 Dwayne Robinson - created
5+
// 2009-12-16 Dwayne Robinson - Updated to support __cdecl too (fclose)
6+
// 2010-07-08 Dwayne Robinson - Updated to handle ref counting policies
7+
// 2014-10-06 Dwayne Robinson - changed to template typedefs
8+
//
69
//----------------------------------------------------------------------------
710
#pragma once
811

@@ -17,9 +20,9 @@
1720
// a reference to it, or zero-initialized. The resource type itself should generally be a simple
1821
// trivially copyable thing such as a pointer or handle type.
1922
template <typename ResourceType = void*> // type of the resource held onto
20-
struct DefaultResourceTypePolicy
23+
struct AutoResourceDefaultPolicy
2124
{
22-
inline static void InitializeEmpty(_Out_ ResourceType* resource) noexcept
25+
inline static void InitializeEmpty(/*out*/ ResourceType* resource) noexcept
2326
{
2427
// Most resources (pointers to memory, HGLOBALS, HGDIOBJ...)
2528
// are indicated as empty by setting to 0/NULL. If a resource
@@ -63,7 +66,7 @@ struct DefaultResourceTypePolicy
6366
// depending on the policy implementation).
6467
template <
6568
typename ResourceType = void*, // type of the resource held onto
66-
typename ResourceTypePolicy = DefaultResourceTypePolicy<ResourceType>,
69+
typename ResourceTypePolicy = AutoResourceDefaultPolicy<ResourceType>,
6770
typename BaseResourceType = ResourceType // type as known by the resource releaser (like HGDIOBJ vs HBITMAP)
6871
>
6972
class AutoResource
@@ -86,9 +89,11 @@ class AutoResource
8689
ResourceTypePolicy::Acquire(resource_);
8790
}
8891

89-
AutoResource(Self&& other)
92+
AutoResource(Self&& /*moveable*/ other)
93+
: resource_(other.resource_)
9094
{
91-
resource_ = other.resource_;
95+
// Just reset the other resource without changing the initialization
96+
// state or reference count.
9297
ResourceTypePolicy::InitializeEmpty(Cast(&other.resource_));
9398
}
9499

@@ -206,7 +211,7 @@ class AutoResource
206211
return *this;
207212
}
208213

209-
inline Self& operator=(const Self& other)
214+
inline Self& operator=(Self const& other)
210215
{
211216
static_assert(ResourceTypePolicy::AllowsMultipleReferences, "This function is only useable on resource types that allow multiple strong references.");
212217
Set(other.resource_);
@@ -300,7 +305,7 @@ class AutoResource
300305
Set(resource);
301306
}
302307

303-
// there is no 'release' alias, since the C++ auto_ptr does something
308+
// There is no release() function, since the C++ auto_ptr does something
304309
// different than typically expected (detaches rather than frees).
305310

306311
protected:
@@ -320,7 +325,9 @@ class AutoResource
320325
return reinterpret_cast<BaseResourceType*>(resource);
321326
}
322327

323-
ResourceType resource_; // could be void*, HANDLE, FILE*, GDIOBJ...
328+
// Specific resource type, such as void*, HANDLE, FILE*, GDIOBJ...
329+
// It is expected to be a simple data type with no copy constructors.
330+
ResourceType resource_;
324331
};
325332

326333

@@ -350,7 +357,7 @@ namespace std
350357
static_assert(sizeof(int*) == sizeof(void*), "Expect all pointers have same size, such as void* and resourceType*");
351358

352359
template <typename ResourceType>
353-
struct UnownedMemoryPointerPolicy : public DefaultResourceTypePolicy<ResourceType>
360+
struct UnownedMemoryPointerPolicy : public AutoResourceDefaultPolicy<ResourceType>
354361
{
355362
// Allow multiple references because the non-owning AutoResource does not strongly hold it anyway.
356363
static const bool AllowsMultipleReferences = true;
@@ -367,7 +374,7 @@ using UnownedMemoryPointer = AutoResource<ResourceType*, UnownedMemoryPointerPol
367374
// Steal'ing from another, or by Detach/Attach.
368375

369376
template <typename ResourceType>
370-
struct OwnedMemoryPointerPolicy : public DefaultResourceTypePolicy<ResourceType>
377+
struct OwnedMemoryPointerPolicy : public AutoResourceDefaultPolicy<ResourceType>
371378
{
372379
inline static void Release(ResourceType resource) noexcept
373380
{

source/DrawingCanvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ inline float Lerp(float first, float last, float fraction)
140140

141141
////////////////////
142142

143-
using GdiPlusStartupAutoResource = AutoResource<ULONG_PTR, HandleResourceTypePolicy<ULONG_PTR, void (WINAPI*)(ULONG_PTR), &Gdiplus::GdiplusShutdown>, ULONG_PTR>;
143+
using GdiPlusStartupAutoResource = AutoResource<ULONG_PTR, AutoResourceHandlePolicy<ULONG_PTR, void (WINAPI*)(ULONG_PTR), &Gdiplus::GdiplusShutdown>, ULONG_PTR>;
144144

145145

146146
class __declspec(uuid("74868E11-F1CF-461A-AEAF-175216DFF0BA")) DrawingCanvas : public ComObject

source/MainWindow.ixx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,38 @@ INT_PTR MainWindow::InitializeMainDialog()
493493
}
494494
SetFocus(GetWindowFromId(hwnd_, controlIdToSetFocusTo));
495495

496+
// For Windows 7, set toolbar button labels to older font characters before Segoe UI Symbol.
497+
DWORD majorWindowsVersion = LOBYTE(LOWORD(GetVersion()));
498+
// GetVersion() is deprecated because it was badly designed and error-prone, but then they messed up and replaced
499+
// a *slightly* error-prone function with a *much more* complicated function like VerifyVersionInfo, where far more
500+
// can go wrong. Yeah, forget you, whoever poorly designed the versioning API's. We're sticking with the simpler
501+
// one here.
502+
if (majorWindowsVersion <= 7)
503+
{
504+
struct ControlIdAndText
505+
{
506+
int id;
507+
wchar_t const* text;
508+
};
509+
ControlIdAndText idsAndText[] =
510+
{
511+
{IdcDrawableObjectListLoad, L"Load"},
512+
{IdcDrawableObjectListStore, L"Save"},
513+
{IdcDrawableObjectCreate, L"+"},
514+
{IdcDrawableObjectDelete, L"-"},
515+
{IdcDrawableObjectCreatePermutations, L"Pm"},
516+
{IdcSelectFontFile, L"File"},
517+
// Already okay:
518+
// IdcDrawableObjectMoveUp
519+
// IdcDrawableObjectMoveDown
520+
// IdcSelectFontFamily
521+
};
522+
for (auto& idAndText : idsAndText)
523+
{
524+
SetWindowText(GetWindowFromId(hwnd_, idAndText.id), idAndText.text);
525+
}
526+
}
527+
496528
#if 0 // hack for debugging animating objects.
497529
SetTimer(hwnd_, IdcUpdateUi + 1, 10, nullptr);
498530
#endif

source/precomp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define NOIME
4242
#endif
4343

44+
#define BUILD_WINDOWS
45+
4446
#define _ENABLE_EXTENDED_ALIGNED_STORAGE // For the SseSizedType case, which is > max_align_t.
4547
#define _SCL_SECURE_NO_WARNINGS // I hate doing this, but Visual Studio offers no substitute for std::uninitialized_copy.
4648

0 commit comments

Comments
 (0)