Added LoadIconMetric() function to drawing better quality icon on HiDPI displays.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Update Version v2.0
|
# Update Version v2.1
|
||||||
# Required module: PSIni
|
# Required module: PSIni
|
||||||
# Installation: Install-Module -Name PsIni
|
# Installation: Install-Module -Name PsIni
|
||||||
|
|
||||||
@@ -36,8 +36,7 @@ function makeVersionString([string]$vmaj, [string]$vmin, [string]$vbld, [string]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[string]$nstr = ($vmaj, $vmin, $vbld, $vrev) -join ','
|
[string]$nstr = ($vmaj, $vmin, $vbld, $vrev) -join ','
|
||||||
$res = @($vstr, $nstr)
|
return @($vstr, $nstr)
|
||||||
return $res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Initializing variables
|
#region Initializing variables
|
||||||
@@ -59,19 +58,20 @@ if (-not (Test-Path $iniFile)) {
|
|||||||
if (Test-Path ".\.git") {
|
if (Test-Path ".\.git") {
|
||||||
$isGit = $true
|
$isGit = $true
|
||||||
[int]$gitCommitCount = [int]$gitRevCount = $null
|
[int]$gitCommitCount = [int]$gitRevCount = $null
|
||||||
[string]$gitRevDate = [string]$gitVerStr = $null
|
[string]$gitRevDate = [string]$gitVerStr = [string]$gitAHash = $null
|
||||||
$gitCommitCount = $(git rev-list --count HEAD)
|
$gitCommitCount = $(git rev-list --count HEAD)
|
||||||
$gitRevDate = $(git log -1 HEAD --date=rfc --pretty=format:%ad%n)
|
$gitRevDate = $(git log -1 HEAD --date=rfc --pretty=format:%ad%n)
|
||||||
$gitVerStr = $(git describe HEAD --long)
|
$gitVerStr = $(git describe HEAD --long)
|
||||||
if ($LastExitCode -eq 0) {
|
if ($LastExitCode -eq 0) {
|
||||||
$gitVerStr = $gitVerStr.Replace('-g', '-')
|
$gitVerStr = $gitVerStr.Replace('-g', '-')
|
||||||
$gitRevCount = $gitVerStr.Split('-')[-2]
|
$gitRevCount = $gitVerStr.Split('-')[-2]
|
||||||
|
$gitAHash = $gitVerStr.Split('-')[-1]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$gitVerStr = ""
|
$gitVerStr = ""
|
||||||
$gitRevCount = $gitCommitCount
|
$gitRevCount = 0
|
||||||
|
$gitAHash = $(git describe HEAD --always)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Reading values from INI file
|
#region Reading values from INI file
|
||||||
@@ -115,8 +115,15 @@ $verRevision = getValue $verRevision
|
|||||||
$vs = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[0]
|
$vs = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[0]
|
||||||
$vn = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[1]
|
$vn = (makeVersionString $verMajor $verMinor $verBuild $verRevision)[1]
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($gitVerStr)) { $pnf = "$pn v$vs" } else { $pnf = "$pn $gitVerStr" }
|
# if ([string]::IsNullOrEmpty($gitVerStr)) { $pnf = "$pn v$vs" } else { $pnf = "$pn $gitVerStr" }
|
||||||
if ($isGit) { $aboutBuild = "Git date: $gitRevDate" } else { $aboutBuild = $buildDateTime }
|
if ($isGit) {
|
||||||
|
$aboutBuild = "Git date: $gitRevDate"
|
||||||
|
$pnf = "$pn v$vs ($gitAHash)"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$aboutBuild = $buildDateTime
|
||||||
|
$pnf = "$pn v$vs"
|
||||||
|
}
|
||||||
|
|
||||||
#region Save all variables to file
|
#region Save all variables to file
|
||||||
"// $pn" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode
|
"// $pn" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode
|
||||||
@@ -134,12 +141,13 @@ if ($isGit) { $aboutBuild = "Git date: $gitRevDate" } else { $aboutBuild = $buil
|
|||||||
"#define VERSION_NUM $vn" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
"#define VERSION_NUM $vn" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
# "#define SPAN_DAYS $spanDays" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# "#define SPAN_DAYS $spanDays" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
# "#define SPAN_SECS $spanSecs" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# "#define SPAN_SECS $spanSecs" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
if ($isGit) {
|
|
||||||
"#define GIT_VERSION_STR `"$gitVerStr`"" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# if ($isGit) {
|
||||||
# "#define GIT_REV_DATE `"Git date: $gitRevDate`"" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# # "#define GIT_VERSION_STR `"$gitVerStr`"" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
# "#define GIT_REV_COUNT $gitRevCount" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# # "#define GIT_REV_DATE `"Git date: $gitRevDate`"" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
# "#define GIT_COMMIT_COUNT $gitCommitCount" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
# # "#define GIT_REV_COUNT $gitRevCount" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
}
|
# # "#define GIT_COMMIT_COUNT $gitCommitCount" | Out-File -FilePath ".\VersionInfo.h" -Encoding unicode -Append
|
||||||
|
# }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Print out all variables
|
#region Print out all variables
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ IF "%~2" == "" GOTO :no_args
|
|||||||
SET solutionDir=%1
|
SET solutionDir=%1
|
||||||
SET projectDir=%2
|
SET projectDir=%2
|
||||||
|
|
||||||
ECHO solutionDir: %solutionDir%
|
|
||||||
ECHO projectDir: %projectDir%
|
|
||||||
|
|
||||||
CD /D %solutionDir%
|
CD /D %solutionDir%
|
||||||
powershell -ExecutionPolicy RemoteSigned -File Update_Version.ps1
|
powershell -ExecutionPolicy RemoteSigned -File Update_Version.ps1
|
||||||
MOVE /Y %solutionDir%VersionInfo.h %projectDir%VersionInfo.h
|
MOVE /Y %solutionDir%VersionInfo.h %projectDir%VersionInfo.h
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ WCHAR szTitle[MAX_LOADSTRING]; // Window's title
|
|||||||
WCHAR szClass[MAX_LOADSTRING]; // Window's class
|
WCHAR szClass[MAX_LOADSTRING]; // Window's class
|
||||||
WCHAR szWinTitle[256];
|
WCHAR szWinTitle[256];
|
||||||
WCHAR szWinClass[256];
|
WCHAR szWinClass[256];
|
||||||
//WCHAR szWinCore[] = L"Windows.UI.Core.CoreWindow";
|
|
||||||
//WCHAR szWorkerW[] = L"WorkerW";
|
|
||||||
HANDLE hHeap = NULL;
|
HANDLE hHeap = NULL;
|
||||||
HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles
|
HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles
|
||||||
HICON hIcon = NULL;
|
HICON hIcon = NULL;
|
||||||
@@ -122,6 +120,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
|||||||
wcex.lpfnWndProc = WndProc;
|
wcex.lpfnWndProc = WndProc;
|
||||||
wcex.hInstance = hInstance;
|
wcex.hInstance = hInstance;
|
||||||
wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
||||||
|
LoadIconMetric(hInst, MAKEINTRESOURCE(IDI_TRAYICON), LIM_LARGE, &(wcex.hIcon));
|
||||||
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||||
wcex.lpszClassName = szClass;
|
wcex.lpszClassName = szClass;
|
||||||
wcex.hIconSm = wcex.hIcon;
|
wcex.hIconSm = wcex.hIcon;
|
||||||
@@ -157,10 +156,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
|||||||
hHeap = GetProcessHeap();
|
hHeap = GetProcessHeap();
|
||||||
szBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, BUF_LEN);
|
szBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, BUF_LEN);
|
||||||
|
|
||||||
//hTaskBar = FindWindowW(L"Shell_TrayWnd", NULL);
|
|
||||||
//hProgman = FindWindowW(L"Progman", NULL);
|
|
||||||
//hDesktop = GetDesktopWindow();
|
|
||||||
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
BOOL bRet;
|
BOOL bRet;
|
||||||
|
|
||||||
@@ -227,9 +222,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
nid.hIcon = hIcon;
|
nid.hIcon = hIcon;
|
||||||
nid.uID = IDI_TRAYICON;
|
nid.uID = IDI_TRAYICON;
|
||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||||
nid.dwInfoFlags = NIIF_NONE;
|
|
||||||
nid.dwState = NIS_HIDDEN;
|
|
||||||
nid.dwStateMask = NIS_HIDDEN;
|
|
||||||
StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
||||||
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
@@ -331,7 +323,6 @@ LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
OutputDebugStringA("Hook Fired!");
|
|
||||||
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
||||||
if (WM_KEYUP == wParam)
|
if (WM_KEYUP == wParam)
|
||||||
{
|
{
|
||||||
@@ -444,7 +435,6 @@ BOOL IsWindowApprooved(HWND hFW)
|
|||||||
bool bApprooved = FALSE;
|
bool bApprooved = FALSE;
|
||||||
if (hFW)
|
if (hFW)
|
||||||
{
|
{
|
||||||
//GetClassNameW(hFW, szWinClass, _countof(szWinClass));
|
|
||||||
if (GetWindowTextW(hFW, (LPWSTR)szBuffer, BUF_LEN - sizeof(WCHAR))) diag_log("Title: '", ConvertWideToUtf8((LPWSTR)szBuffer), "'");
|
if (GetWindowTextW(hFW, (LPWSTR)szBuffer, BUF_LEN - sizeof(WCHAR))) diag_log("Title: '", ConvertWideToUtf8((LPWSTR)szBuffer), "'");
|
||||||
if (IsIconic(hFW)) diag_log("Window is iconic");
|
if (IsIconic(hFW)) diag_log("Window is iconic");
|
||||||
if (IsZoomed(hFW)) diag_log("Window is maximized");
|
if (IsZoomed(hFW)) diag_log("Window is maximized");
|
||||||
@@ -459,20 +449,6 @@ BOOL IsWindowApprooved(HWND hFW)
|
|||||||
else ShowError(IDS_ERR_MAXMIN);
|
else ShowError(IDS_ERR_MAXMIN);
|
||||||
}
|
}
|
||||||
else diag_log("The window has no caption");
|
else diag_log("The window has no caption");
|
||||||
|
|
||||||
//if ((wcscmp(szWinClass, szWinCore) != 0) &&
|
|
||||||
// (wcscmp(szWinClass, szWorkerW) != 0) &&
|
|
||||||
// (hFW != hDesktop && hFW != hTaskBar && hFW != hProgman))
|
|
||||||
//{
|
|
||||||
// if (!IsIconic(hFW) && !IsZoomed(hFW))
|
|
||||||
// {
|
|
||||||
// diag_log("Window is approved");
|
|
||||||
// bApprooved = TRUE;
|
|
||||||
// }
|
|
||||||
// else ShowError(IDS_ERR_MAXMIN);
|
|
||||||
//}
|
|
||||||
//else diag_log("The window belongs to the Windows environment");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!bApprooved) diag_log("Window is not approved!");
|
if (!bApprooved) diag_log("Window is not approved!");
|
||||||
diag_log("Quiting IsWindowApprooved()");
|
diag_log("Quiting IsWindowApprooved()");
|
||||||
@@ -488,10 +464,12 @@ VOID HandlingTrayIcon()
|
|||||||
diag_log("Shell_NotifyIconW(NIM_ADD): ", bResult1);
|
diag_log("Shell_NotifyIconW(NIM_ADD): ", bResult1);
|
||||||
bool bResult2 = Shell_NotifyIconW(NIM_SETVERSION, &nid);
|
bool bResult2 = Shell_NotifyIconW(NIM_SETVERSION, &nid);
|
||||||
diag_log("Shell_NotifyIconW(NIM_SETVERSION): ", bResult2);
|
diag_log("Shell_NotifyIconW(NIM_SETVERSION): ", bResult2);
|
||||||
|
Shell_NotifyIconW(NIM_MODIFY, &nid);
|
||||||
if (!bResult1 || !bResult2)
|
if (!bResult1 || !bResult2)
|
||||||
{
|
{
|
||||||
diag_log("Error creating trayicon!");
|
diag_log("Error creating trayicon!");
|
||||||
ShowError(IDS_ERR_ICON);
|
ShowError(IDS_ERR_ICON);
|
||||||
|
Shell_NotifyIconW(NIM_DELETE, &nid);
|
||||||
bShowIcon = FALSE;
|
bShowIcon = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user