Skip to content

Commit

Permalink
Merge pull request #11 from hatelamers/feature/3-make-the-app-hidpi-a…
Browse files Browse the repository at this point in the history
…ware

#3 implemented HiDPI support
  • Loading branch information
hatelamers authored Nov 16, 2024
2 parents ce19388 + a4058d4 commit 946867f
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 36 deletions.
3 changes: 2 additions & 1 deletion buildenv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ endif()

include("${CMAKE_CURRENT_LIST_DIR}/LocalBuild.cmake" OPTIONAL)

include("${CMAKE_CURRENT_LIST_DIR}/Product.cmake")
file(READ "${CMAKE_CURRENT_LIST_DIR}/buildnumber.txt" BUILD_NUMBER)
include("${CMAKE_CURRENT_LIST_DIR}/Product.cmake")
if(NOT ${BUILD_NUMBER})
set(BUILD_NUMBER 1)
endif()
Expand Down Expand Up @@ -43,6 +43,7 @@ set(MAIN_TARGET_SOURCE_DIR "${WORKSPACE_ROOT}/src/app")
set(MAIN_TARGET_RESOURCE_DIR "${MAIN_TARGET_SOURCE_DIR}/res")

configure_file("${MAIN_TARGET_SOURCE_DIR}/productmeta.h.in" "${MAIN_TARGET_SOURCE_DIR}/productmeta.h")
configure_file("${MAIN_TARGET_SOURCE_DIR}/app.manifest.in" "${MAIN_TARGET_RESOURCE_DIR}/app.manifest")

add_custom_target(${MAIN_TARGET_NAME} ALL)

Expand Down
2 changes: 1 addition & 1 deletion buildenv/buildnumber.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26
28
8 changes: 8 additions & 0 deletions src/app/AboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
uxTheme.AllowDarkModeForWindow(m_hWnd, true);
if (uxTheme.ShouldAppsUseDarkMode())
{
uxTheme.SwitchWindowDarkMode(m_hWnd, true);
}
SetThemeExtendedStyle(THEME_EX_THEMECLIENTEDGE);
//EnableThemeDialogTexture(ETDT_ENABLETAB);

DoDataExchange(FALSE);
//m_lnkLicense.SetHyperLinkExtendedStyle(HLINK_COMMANDBUTTON, HLINK_COMMANDBUTTON);
if (m_fvi.Open())
Expand Down
2 changes: 2 additions & 0 deletions src/app/AboutDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class CAboutDlg
: public CDialogImpl<CAboutDlg>
, public CThemeImpl<CAboutDlg>
, public CWinDataExchange<CAboutDlg>
{
public:
Expand All @@ -17,6 +18,7 @@ class CAboutDlg
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
COMMAND_ID_HANDLER(IDRETRY, OnCloseCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
CHAIN_MSG_MAP(CThemeImpl<CAboutDlg>)
END_MSG_MAP()

BEGIN_DDX_MAP(CAboutDlg)
Expand Down
3 changes: 1 addition & 2 deletions src/app/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/

LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
m_mnuMain.Detach();

// unregister message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->RemoveMessageFilter(this);
pLoop->RemoveIdleHandler(this);

bHandled = FALSE;
PostQuitMessage(0);
return 1;
}

Expand Down
6 changes: 4 additions & 2 deletions src/app/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#define MNUPOS_APP_EXIT 0

class CMainFrame :
public CFrameWindowImpl<CMainFrame>,
public CFrameWindowImpl<CMainFrame>,
public CThemeImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler, public CShellBrowseMenu::ShellMenuController
{
Expand Down Expand Up @@ -49,6 +50,7 @@ class CMainFrame :
MESSAGE_HANDLER(GetDisplayPopupMessage(), OnDisplayPopup)
COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)
COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
CHAIN_MSG_MAP(CThemeImpl<CMainFrame>)
CHAIN_MSG_MAP_MEMBER(m_shellMenu)
MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
Expand Down Expand Up @@ -80,7 +82,7 @@ class CMainFrame :
public:
bool m_hasChildren{ false };
private:
CMenu m_mnuMain;
CMenuHandle m_mnuMain;
CShellBrowseMenu m_shellMenu;
CString m_strActionSource;
CString m_strSourceTitle;
Expand Down
22 changes: 17 additions & 5 deletions src/app/WinPinMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MainFrm.h"

CAppModule _Module;
CUxTheme uxTheme;

class CWinPinMenuThreadManager
{
Expand Down Expand Up @@ -36,13 +37,24 @@ class CWinPinMenuThreadManager
_RunData* pData = (_RunData*)lpData;
CMainFrame wndFrame;

RECT rc{ -1000, -1000, -950, -950 };
if(wndFrame.CreateEx(NULL, &rc, WS_ICONIC) == NULL)
RECT rc{ -1000, -1000, 0, 0 };
POINT pt{ 0,0 };
if (::GetCursorPos(&pt))
{
rc.left = pt.x;
rc.top = pt.y;
}
if(wndFrame.CreateEx(NULL, &rc, WS_POPUP) == NULL)
{
ATLTRACE(_T("Frame window creation failed!\n"));
return 0;
}

uxTheme.AllowDarkModeForWindow(wndFrame, true);
if (uxTheme.ShouldAppsUseDarkMode())
{
uxTheme.SwitchWindowDarkMode(wndFrame, true);
}
wndFrame.ShowWindow(pData->nCmdShow);
delete pData;

Expand Down Expand Up @@ -135,13 +147,13 @@ class CWinPinMenuThreadManager

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
CUxTheme uxTheme;
uxTheme.SetPreferredAppMode(PreferredAppMode::AllowDark);
// TODO: intrusive dark mode doesn't support owner-drawn menus, we need to paint all ourselves
//uxTheme.SetPreferredAppMode(PreferredAppMode::AllowDark);

HRESULT hRes = ::CoInitialize(NULL);
ATLASSERT(SUCCEEDED(hRes));

AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
AtlInitCommonControls(ICC_STANDARD_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls

hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
Expand Down
13 changes: 11 additions & 2 deletions src/app/WinPinMenu.rc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ IDR_MAINFRAME ICON "res\\app.ico"

IDI_APP_RUNNING ICON "res\\app_running.ico"


/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//

1 RT_MANIFEST "res\\app.manifest"

#endif // Neutral (Default) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -93,8 +101,8 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION | WS_S
CAPTION "About"
FONT 9, "Segoe UI", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "O&K",IDOK,185,113,50,14
PUSHBUTTON "&Back To Menu",IDRETRY,131,113,50,14
DEFPUSHBUTTON "O&K",IDOK,179,106,50,14
PUSHBUTTON "&Back To Menu",IDRETRY,122,106,50,14
ICON IDR_MAINFRAME,IDC_STATIC,12,15,20,20
GROUPBOX "",IDC_STATIC,7,7,228,120
LTEXT "Product Name",IDC_TXT_PRODUCTNAME,41,15,125,18
Expand Down Expand Up @@ -134,6 +142,7 @@ BEGIN
HORZGUIDE, 15
HORZGUIDE, 39
HORZGUIDE, 68
HORZGUIDE, 120
END
END
#endif // APSTUDIO_INVOKED
Expand Down
9 changes: 9 additions & 0 deletions src/app/WinPinMenu.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,37 @@
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\build\$(Configuration)-$(PlatformShortName)\</OutDir>
<IntDir>..\..\build\$(Configuration)-$(PlatformShortName)\</IntDir>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -345,6 +351,9 @@
<None Include="packages.config" />
<None Include="res\WinPinMenu.rc2" />
</ItemGroup>
<ItemGroup>
<Manifest Include="res\app.manifest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\buildenv\packages\wtl.10.0.10320\build\native\wtl.targets" Condition="Exists('..\..\buildenv\packages\wtl.10.0.10320\build\native\wtl.targets')" />
Expand Down
5 changes: 5 additions & 0 deletions src/app/WinPinMenu.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Manifest Include="res\app.manifest">
<Filter>Resource Files</Filter>
</Manifest>
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions src/app/app.manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity processorArchitecture="*" type="win32" name="${PRODUCT_IDENTIFIER}" version="${PRODUCT_VERSION}"/>
<description>${PRODUCT_DESCRIPTON}</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<asmv2:trustInfo xmlns:asmv2="urn:schemas-microsoft-com:asm.v2">
<asmv2:security>
<asmv2:requestedPrivileges>
<asmv2:requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</asmv2:requestedPrivileges>
</asmv2:security>
</asmv2:trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, system</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10, 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
6 changes: 3 additions & 3 deletions src/app/productmeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define PRODUCT_VERSION_MAJOR 0
#define PRODUCT_VERSION_MINOR 1
#define PRODUCT_VERSION_PATCH 1
#define PRODUCT_VERSION_TWEAK 26
#define PRODUCT_VERSION_TWEAK 28
#define PRODUCT_NAME _T("WinPinMenu\0")
#define PRODUCT_DESCRIPTION _T("diVISION Pinnable Taskbar Menu For Windows\0")
#define PRODUCT_HOMEPAGE_URL _T("https://github.com/hatelamers/WinPinMenu\0")
Expand All @@ -19,5 +19,5 @@
#define FILE_NAME _T("WinPinMenu\0")
#define FILE_DESCRIPTION _T("diVISION Pinnable Taskbar Menu For Windows\0")

#define FILE_VERSION 0,1,1,26
#define FILE_VERSION_S _T("0.1.1.26\0")
#define FILE_VERSION 0,1,1,28
#define FILE_VERSION_S _T("0.1.1.28\0")
35 changes: 35 additions & 0 deletions src/app/res/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity processorArchitecture="*" type="win32" name="winpinmenu" version="0.1.1.28"/>
<description>diVISION Pinnable Taskbar Menu For Windows</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<asmv2:trustInfo xmlns:asmv2="urn:schemas-microsoft-com:asm.v2">
<asmv2:security>
<asmv2:requestedPrivileges>
<asmv2:requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</asmv2:requestedPrivileges>
</asmv2:security>
</asmv2:trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, system</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10, 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
4 changes: 2 additions & 2 deletions src/app/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define IDR_MAINFRAME 128
#define IDI_ICON1 202
#define IDI_APP_RUNNING 202
#define IDR_RT_MANIFEST1 203
#define IDC_TXT_PRODUCTNAME 1000
#define IDC_LNK_LICENSE 1001
#define IDC_TXT_COMPANYNAME 1002
Expand All @@ -15,7 +16,6 @@
#define IDC_TXT_PRODUCTVERSION 1005
#define IDC_TXT_FILEVERSION 1006
#define IDC_TXT_LEGALCOPYRIGHT 1007
#define IDC_BUTTON1 1008
#define IDS_EMPTY_FOLDER 32772
#define IDS_INVALID_SOURCE 32773
#define ID_FILE_NOACTIONSOURCE 32775
Expand All @@ -24,7 +24,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 203
#define _APS_NEXT_RESOURCE_VALUE 204
#define _APS_NEXT_COMMAND_VALUE 32776
#define _APS_NEXT_CONTROL_VALUE 1009
#define _APS_NEXT_SYMED_VALUE 102
Expand Down
23 changes: 14 additions & 9 deletions src/app/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <tuple>

#include <dwmapi.h>

#include <atlbase.h>
#if (_ATL_VER >= 0x0700)
#include <atlstr.h>
Expand All @@ -31,18 +33,21 @@ extern CAppModule _Module;
#include <atlctrlx.h>
#include <atlddx.h>
#include <atldlgs.h>
#include <atltheme.h>

#include <commoncontrols.h>

#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
//#if defined _M_IX86
// #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
//#elif defined _M_IA64
// #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
//#elif defined _M_X64
// #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
//#else
// #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
//#endif

#include "taskbarautomation.h"
#include "uxthemehelper.h"

extern CUxTheme uxTheme;
Loading

0 comments on commit 946867f

Please sign in to comment.