mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Merge remote-tracking branch 'upstream/master' into locPowerRename
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</Capabilities>
|
||||
<Applications>
|
||||
<Application Id="PowerToys" Executable="PowerToys.exe" EntryPoint="Windows.FullTrustApplication">
|
||||
<uap:VisualElements DisplayName="PowerToys" Description="Windows system utilities to maximize productivity" Square150x150Logo="Images\logo150.png" Square44x44Logo="Images\logo44.png" BackgroundColor="transparent" />
|
||||
<uap:VisualElements DisplayName="PowerToys (Preview)" Description="Windows system utilities to maximize productivity" Square150x150Logo="Images\logo150.png" Square44x44Logo="Images\logo44.png" BackgroundColor="transparent" />
|
||||
<Extensions>
|
||||
<uap5:Extension Category="windows.startupTask" Executable="PowerToys.exe" EntryPoint="Windows.FullTrustApplication">
|
||||
<uap5:StartupTask TaskId="PowerToysStartupTaskID" Enabled="true" DisplayName="PowerToys" />
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
taskkill /f /im explorer.exe
|
||||
|
||||
Get-AppxPackage -Name 'PowerToys' | select -ExpandProperty "PackageFullName" | Remove-AppxPackage
|
||||
|
||||
.\build_msix.ps1
|
||||
signtool sign /debug /a /fd SHA256 /f PowerToys_TemporaryKey.pfx /p 12345 bin\PowerToys-x64.msix
|
||||
signtool sign /debug /a /fd SHA256 /f PowerToys_TemporaryKey.pfx /p 12345 bin\PowerToys.msixbundle
|
||||
|
||||
Add-AppxPackage .\bin\PowerToys-x64.msix
|
||||
|
||||
start $Env:windir\explorer.exe
|
||||
@@ -7,14 +7,21 @@
|
||||
* The resulting installer will be built to `PowerToysSetup\bin\Release\PowerToysSetup.msi`.
|
||||
|
||||
## Building and installing self-signed PowerToys MSIX package
|
||||
For the first-time installation, you should generate a self-signed certificate and add it to the [TRCA store](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/trusted-root-certification-authorities-certificate-store). That could be done by simply running `
|
||||
generate_self_sign_cert.ps1` from a powershell admin. After that:
|
||||
For the first-time installation, you'll need to generate a self-signed certificate. The script below will generate and add a cert to your [TRCA store](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/trusted-root-certification-authorities-certificate-store).
|
||||
1. Open `Developer PowerShell for VS` as an Admin
|
||||
2. Navigate to your repo's `installer\MSIX`
|
||||
3. Run `.\generate_self_sign_cert.ps1`
|
||||
|
||||
* Make sure you've built the `Release` configuration of `powertoys.sln`
|
||||
* Launch `msix_reinstall.ps1` from the devenv powershell
|
||||
## To Build
|
||||
1. Make sure you've built the `Release` configuration of `powertoys.sln`
|
||||
2. Open `Developer PowerShell for VS`
|
||||
3. Navigate to your repo's `installer\MSIX`
|
||||
4. Run `.\msix_reinstall.ps1` from the devenv powershell
|
||||
|
||||
### What msix_reinstall.ps1 does
|
||||
`msix_reinstall.ps1` removes the current PowerToys installation, restarts explorer.exe (to update PowerRename shell extension), builds `PowerToys-x64.msix` package, signs it with a PowerToys_TemporaryKey.pfx, and finally installs it.
|
||||
## Removing all .msi/.msix PowerToys installations
|
||||
|
||||
#### Removing all .msi/.msix PowerToys installations
|
||||
```ps
|
||||
$name='PowerToys'
|
||||
Get-AppxPackage -Name $name | select -ExpandProperty "PackageFullName" | Remove-AppxPackage
|
||||
|
||||
@@ -97,6 +97,8 @@
|
||||
<ClInclude Include="d2d_text.h" />
|
||||
<ClInclude Include="d2d_window.h" />
|
||||
<ClInclude Include="dpi_aware.h" />
|
||||
<ClInclude Include="window_helpers.h" />
|
||||
<ClInclude Include="icon_helpers.h" />
|
||||
<ClInclude Include="hwnd_data_cache.h" />
|
||||
<ClInclude Include="json.h" />
|
||||
<ClInclude Include="monitors.h" />
|
||||
@@ -130,10 +132,12 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="settings_helpers.cpp" />
|
||||
<ClCompile Include="settings_objects.cpp" />
|
||||
<ClCompile Include="icon_helpers.cpp" />
|
||||
<ClCompile Include="start_visible.cpp" />
|
||||
<ClCompile Include="tasklist_positions.cpp" />
|
||||
<ClCompile Include="common.cpp" />
|
||||
<ClCompile Include="windows_colors.cpp" />
|
||||
<ClCompile Include="window_helpers.cpp" />
|
||||
<ClCompile Include="winstore.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -81,6 +81,12 @@
|
||||
<ClInclude Include="winstore.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="icon_helpers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="window_helpers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="d2d_svg.cpp">
|
||||
@@ -132,5 +138,11 @@
|
||||
<ClCompile Include="winstore.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="icon_helpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="window_helpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
90
src/common/icon_helpers.cpp
Normal file
90
src/common/icon_helpers.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "icon_helpers.h"
|
||||
#include "pch.h"
|
||||
|
||||
HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index)
|
||||
{
|
||||
*index = 0;
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
SHFILEINFO shFileInfo = { 0 };
|
||||
|
||||
if (!PathIsRelative(path))
|
||||
{
|
||||
DWORD attrib = GetFileAttributes(path);
|
||||
HIMAGELIST himl = (HIMAGELIST)SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
|
||||
if (himl)
|
||||
{
|
||||
*index = shFileInfo.iIcon;
|
||||
// We shouldn't free the HIMAGELIST.
|
||||
hr = S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width, _In_opt_ UINT height)
|
||||
{
|
||||
HBITMAP hBitmapResult = NULL;
|
||||
|
||||
// Create compatible DC
|
||||
HDC hDC = CreateCompatibleDC(NULL);
|
||||
if (hDC != NULL)
|
||||
{
|
||||
// Get bitmap rectangle size
|
||||
RECT rc = { 0 };
|
||||
rc.left = 0;
|
||||
rc.right = (width != 0) ? width : GetSystemMetrics(SM_CXSMICON);
|
||||
rc.top = 0;
|
||||
rc.bottom = (height != 0) ? height : GetSystemMetrics(SM_CYSMICON);
|
||||
|
||||
// Create bitmap compatible with DC
|
||||
BITMAPINFO BitmapInfo;
|
||||
ZeroMemory(&BitmapInfo, sizeof(BITMAPINFO));
|
||||
|
||||
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
BitmapInfo.bmiHeader.biWidth = rc.right;
|
||||
BitmapInfo.bmiHeader.biHeight = rc.bottom;
|
||||
BitmapInfo.bmiHeader.biPlanes = 1;
|
||||
BitmapInfo.bmiHeader.biBitCount = 32;
|
||||
BitmapInfo.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
HDC hDCBitmap = GetDC(NULL);
|
||||
|
||||
HBITMAP hBitmap = CreateDIBSection(hDCBitmap, &BitmapInfo, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||
|
||||
ReleaseDC(NULL, hDCBitmap);
|
||||
|
||||
if (hBitmap != NULL)
|
||||
{
|
||||
// Select bitmap into DC
|
||||
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDC, hBitmap);
|
||||
if (hBitmapOld != NULL)
|
||||
{
|
||||
// Draw icon into DC
|
||||
if (DrawIconEx(hDC, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
|
||||
{
|
||||
// Restore original bitmap in DC
|
||||
hBitmapResult = (HBITMAP)SelectObject(hDC, hBitmapOld);
|
||||
hBitmapOld = NULL;
|
||||
hBitmap = NULL;
|
||||
}
|
||||
|
||||
if (hBitmapOld != NULL)
|
||||
{
|
||||
SelectObject(hDC, hBitmapOld);
|
||||
}
|
||||
}
|
||||
|
||||
if (hBitmap != NULL)
|
||||
{
|
||||
DeleteObject(hBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteDC(hDC);
|
||||
}
|
||||
|
||||
return hBitmapResult;
|
||||
}
|
||||
5
src/common/icon_helpers.h
Normal file
5
src/common/icon_helpers.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index);
|
||||
HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width = 0, _In_opt_ UINT height = 0);
|
||||
30
src/common/window_helpers.cpp
Normal file
30
src/common/window_helpers.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "window_helpers.h"
|
||||
#include "pch.h"
|
||||
|
||||
HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p)
|
||||
{
|
||||
WNDCLASS wc = { 0 };
|
||||
|
||||
PCWSTR wndClassName = L"MsgWindow";
|
||||
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.cbWndExtra = sizeof(void*);
|
||||
wc.hInstance = hInst;
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = wndClassName;
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
HWND hwnd = CreateWindowEx(
|
||||
0, wndClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInst, nullptr);
|
||||
if (hwnd)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)p);
|
||||
if (pfnWndProc)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnWndProc);
|
||||
}
|
||||
}
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
4
src/common/window_helpers.h
Normal file
4
src/common/window_helpers.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p);
|
||||
@@ -558,22 +558,23 @@ namespace FancyZonesEditor
|
||||
|
||||
Settings settings = ((App)Application.Current).ZoneSettings;
|
||||
|
||||
int spacing = settings.ShowSpacing ? settings.Spacing : 0;
|
||||
int spacing, gutter;
|
||||
spacing = gutter = settings.ShowSpacing ? settings.Spacing : 0;
|
||||
|
||||
int cols = model.Columns;
|
||||
int rows = model.Rows;
|
||||
|
||||
double totalWidth = arrangeSize.Width - (spacing * (cols + 1));
|
||||
double totalHeight = arrangeSize.Height - (spacing * (rows + 1));
|
||||
double totalWidth = arrangeSize.Width - (gutter * 2) - (spacing * (cols - 1));
|
||||
double totalHeight = arrangeSize.Height - (gutter * 2) - (spacing * (rows - 1));
|
||||
|
||||
double top = spacing;
|
||||
double top = gutter;
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
double cellHeight = _rowInfo[row].Recalculate(top, totalHeight);
|
||||
top += cellHeight + spacing;
|
||||
}
|
||||
|
||||
double left = spacing;
|
||||
double left = gutter;
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
double cellWidth = _colInfo[col].Recalculate(left, totalWidth);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
mc:Ignorable="d"
|
||||
Background="LightGray"
|
||||
BorderThickness="1"
|
||||
BorderBrush="DarkGray"
|
||||
BorderBrush="SlateGray"
|
||||
Opacity="0.5"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid x:Name="Frame" Visibility="Collapsed">
|
||||
|
||||
@@ -98,98 +98,9 @@ namespace FancyZonesEditor
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderActualScalePriview(GridLayoutModel grid)
|
||||
{
|
||||
int rows = grid.Rows;
|
||||
int cols = grid.Columns;
|
||||
|
||||
RowColInfo[] rowInfo = new RowColInfo[rows];
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
rowInfo[row] = new RowColInfo(grid.RowPercents[row]);
|
||||
}
|
||||
|
||||
RowColInfo[] colInfo = new RowColInfo[cols];
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
colInfo[col] = new RowColInfo(grid.ColumnPercents[col]);
|
||||
}
|
||||
|
||||
Settings settings = ((App)Application.Current).ZoneSettings;
|
||||
|
||||
int spacing = settings.ShowSpacing ? settings.Spacing : 0;
|
||||
|
||||
int width = (int)SystemParameters.WorkArea.Width;
|
||||
int height = (int)SystemParameters.WorkArea.Height;
|
||||
|
||||
double totalWidth = width - (spacing * (cols + 1));
|
||||
double totalHeight = height - (spacing * (rows + 1));
|
||||
|
||||
double top = spacing;
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
double cellHeight = rowInfo[row].Recalculate(top, totalHeight);
|
||||
top += cellHeight + spacing;
|
||||
}
|
||||
|
||||
double left = spacing;
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
double cellWidth = colInfo[col].Recalculate(left, totalWidth);
|
||||
left += cellWidth + spacing;
|
||||
}
|
||||
|
||||
Viewbox viewbox = new Viewbox
|
||||
{
|
||||
Stretch = Stretch.Uniform,
|
||||
};
|
||||
Body.Children.Add(viewbox);
|
||||
Canvas frame = new Canvas
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
};
|
||||
viewbox.Child = frame;
|
||||
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
int i = grid.CellChildMap[row, col];
|
||||
if (((row == 0) || (grid.CellChildMap[row - 1, col] != i)) &&
|
||||
((col == 0) || (grid.CellChildMap[row, col - 1] != i)))
|
||||
{
|
||||
Rectangle rect = new Rectangle();
|
||||
left = colInfo[col].Start;
|
||||
top = rowInfo[row].Start;
|
||||
Canvas.SetTop(rect, top);
|
||||
Canvas.SetLeft(rect, left);
|
||||
|
||||
int maxRow = row;
|
||||
while (((maxRow + 1) < rows) && (grid.CellChildMap[maxRow + 1, col] == i))
|
||||
{
|
||||
maxRow++;
|
||||
}
|
||||
|
||||
int maxCol = col;
|
||||
while (((maxCol + 1) < cols) && (grid.CellChildMap[row, maxCol + 1] == i))
|
||||
{
|
||||
maxCol++;
|
||||
}
|
||||
|
||||
rect.Width = colInfo[maxCol].End - left;
|
||||
rect.Height = rowInfo[maxRow].End - top;
|
||||
rect.StrokeThickness = 1;
|
||||
rect.Stroke = Brushes.DarkGray;
|
||||
rect.Fill = Brushes.LightGray;
|
||||
frame.Children.Add(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderSmallScalePriview(GridLayoutModel grid)
|
||||
private void RenderGridPreview(GridLayoutModel grid)
|
||||
{
|
||||
Body.RowDefinitions.Clear();
|
||||
foreach (int percent in grid.RowPercents)
|
||||
{
|
||||
RowDefinition def = new RowDefinition
|
||||
@@ -199,6 +110,7 @@ namespace FancyZonesEditor
|
||||
Body.RowDefinitions.Add(def);
|
||||
}
|
||||
|
||||
Body.ColumnDefinitions.Clear();
|
||||
foreach (int percent in grid.ColumnPercents)
|
||||
{
|
||||
ColumnDefinition def = new ColumnDefinition
|
||||
@@ -209,7 +121,8 @@ namespace FancyZonesEditor
|
||||
}
|
||||
|
||||
Settings settings = ((App)Application.Current).ZoneSettings;
|
||||
Thickness margin = new Thickness(settings.ShowSpacing ? settings.Spacing / 20 : 0);
|
||||
int divisor = IsActualSize ? 2 : 20;
|
||||
Thickness margin = new Thickness(settings.ShowSpacing ? settings.Spacing / divisor : 0);
|
||||
|
||||
List<int> visited = new List<int>();
|
||||
|
||||
@@ -224,25 +137,25 @@ namespace FancyZonesEditor
|
||||
Rectangle rect = new Rectangle();
|
||||
Grid.SetRow(rect, row);
|
||||
Grid.SetColumn(rect, col);
|
||||
int rowSpan = 1;
|
||||
int span = 1;
|
||||
int walk = row + 1;
|
||||
while ((walk < grid.Rows) && grid.CellChildMap[walk, col] == childIndex)
|
||||
{
|
||||
rowSpan++;
|
||||
span++;
|
||||
walk++;
|
||||
}
|
||||
|
||||
Grid.SetRowSpan(rect, rowSpan);
|
||||
Grid.SetRowSpan(rect, span);
|
||||
|
||||
int columnSpan = 1;
|
||||
span = 1;
|
||||
walk = col + 1;
|
||||
while ((walk < grid.Columns) && grid.CellChildMap[row, walk] == childIndex)
|
||||
{
|
||||
columnSpan++;
|
||||
span++;
|
||||
walk++;
|
||||
}
|
||||
|
||||
Grid.SetColumnSpan(rect, columnSpan);
|
||||
Grid.SetColumnSpan(rect, span);
|
||||
|
||||
rect.Margin = margin;
|
||||
rect.StrokeThickness = 1;
|
||||
@@ -254,20 +167,6 @@ namespace FancyZonesEditor
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderGridPreview(GridLayoutModel grid)
|
||||
{
|
||||
Body.RowDefinitions.Clear();
|
||||
Body.ColumnDefinitions.Clear();
|
||||
if (IsActualSize)
|
||||
{
|
||||
RenderActualScalePriview(grid);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSmallScalePriview(grid);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderCanvasPreview(CanvasLayoutModel canvas)
|
||||
{
|
||||
Body.RowDefinitions.Clear();
|
||||
|
||||
@@ -49,7 +49,7 @@ IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneSet::ZoneFromPoint(POINT pt) noexcept
|
||||
winrt::com_ptr<IZone> smallestKnownZone = nullptr;
|
||||
// To reduce redundant calculations, we will store the last known zones area.
|
||||
int smallestKnownZoneArea = INT32_MAX;
|
||||
for (auto iter = m_zones.begin(); iter != m_zones.end(); iter++)
|
||||
for (auto iter = m_zones.rbegin(); iter != m_zones.rend(); iter++)
|
||||
{
|
||||
if (winrt::com_ptr<IZone> zone = iter->try_as<IZone>())
|
||||
{
|
||||
|
||||
@@ -553,7 +553,7 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
auto zones = m_activeZoneSet->GetZones();
|
||||
const size_t maxColorIndex = min(size(zones) - 1, size(colors) - 1);
|
||||
size_t colorIndex = maxColorIndex;
|
||||
for (auto iter = zones.rbegin(); iter != zones.rend(); iter++)
|
||||
for (auto iter = zones.begin(); iter != zones.end(); iter++)
|
||||
{
|
||||
winrt::com_ptr<IZone> zone = iter->try_as<IZone>();
|
||||
if (!zone)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <trace.h>
|
||||
#include <common.h>
|
||||
#include <Helpers.h>
|
||||
#include <icon_helpers.h>
|
||||
#include <Settings.h>
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
@@ -2,94 +2,6 @@
|
||||
#include "Helpers.h"
|
||||
#include <ShlGuid.h>
|
||||
|
||||
HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index)
|
||||
{
|
||||
*index = 0;
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
SHFILEINFO shFileInfo = { 0 };
|
||||
|
||||
if (!PathIsRelative(path))
|
||||
{
|
||||
DWORD attrib = GetFileAttributes(path);
|
||||
HIMAGELIST himl = (HIMAGELIST)SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
|
||||
if (himl)
|
||||
{
|
||||
*index = shFileInfo.iIcon;
|
||||
// We shouldn't free the HIMAGELIST.
|
||||
hr = S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width, _In_opt_ UINT height)
|
||||
{
|
||||
HBITMAP hBitmapResult = NULL;
|
||||
|
||||
// Create compatible DC
|
||||
HDC hDC = CreateCompatibleDC(NULL);
|
||||
if (hDC != NULL)
|
||||
{
|
||||
// Get bitmap rectangle size
|
||||
RECT rc = { 0 };
|
||||
rc.left = 0;
|
||||
rc.right = (width != 0) ? width : GetSystemMetrics(SM_CXSMICON);
|
||||
rc.top = 0;
|
||||
rc.bottom = (height != 0) ? height : GetSystemMetrics(SM_CYSMICON);
|
||||
|
||||
// Create bitmap compatible with DC
|
||||
BITMAPINFO BitmapInfo;
|
||||
ZeroMemory(&BitmapInfo, sizeof(BITMAPINFO));
|
||||
|
||||
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
BitmapInfo.bmiHeader.biWidth = rc.right;
|
||||
BitmapInfo.bmiHeader.biHeight = rc.bottom;
|
||||
BitmapInfo.bmiHeader.biPlanes = 1;
|
||||
BitmapInfo.bmiHeader.biBitCount = 32;
|
||||
BitmapInfo.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
HDC hDCBitmap = GetDC(NULL);
|
||||
|
||||
HBITMAP hBitmap = CreateDIBSection(hDCBitmap, &BitmapInfo, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||
|
||||
ReleaseDC(NULL, hDCBitmap);
|
||||
|
||||
if (hBitmap != NULL)
|
||||
{
|
||||
// Select bitmap into DC
|
||||
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDC, hBitmap);
|
||||
if (hBitmapOld != NULL)
|
||||
{
|
||||
// Draw icon into DC
|
||||
if (DrawIconEx(hDC, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
|
||||
{
|
||||
// Restore original bitmap in DC
|
||||
hBitmapResult = (HBITMAP)SelectObject(hDC, hBitmapOld);
|
||||
hBitmapOld = NULL;
|
||||
hBitmap = NULL;
|
||||
}
|
||||
|
||||
if (hBitmapOld != NULL)
|
||||
{
|
||||
SelectObject(hDC, hBitmapOld);
|
||||
}
|
||||
}
|
||||
|
||||
if (hBitmap != NULL)
|
||||
{
|
||||
DeleteObject(hBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteDC(hDC);
|
||||
}
|
||||
|
||||
return hBitmapResult;
|
||||
}
|
||||
|
||||
HRESULT _ParseEnumItems(_In_ IEnumShellItems* pesi, _In_ IPowerRenameManager* psrm, _In_ int depth = 0)
|
||||
{
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
@@ -167,33 +79,6 @@ HRESULT EnumerateDataObject(_In_ IUnknown* dataSource, _In_ IPowerRenameManager*
|
||||
return hr;
|
||||
}
|
||||
|
||||
HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p)
|
||||
{
|
||||
WNDCLASS wc = { 0 };
|
||||
PWSTR wndClassName = L"MsgWindow";
|
||||
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.cbWndExtra = sizeof(void*);
|
||||
wc.hInstance = hInst;
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = wndClassName;
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
HWND hwnd = CreateWindowEx(
|
||||
0, wndClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInst, nullptr);
|
||||
if (hwnd)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)p);
|
||||
if (pfnWndProc)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnWndProc);
|
||||
}
|
||||
}
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
BOOL GetEnumeratedFileName(__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax, __in PCWSTR pszTemplate, __in_opt PCWSTR pszDir, unsigned long ulMinLong, __inout unsigned long* pulNumUsed)
|
||||
{
|
||||
PWSTR pszName = nullptr;
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
#include <lib/PowerRenameInterfaces.h>
|
||||
|
||||
HRESULT EnumerateDataObject(_In_ IUnknown* pdo, _In_ IPowerRenameManager* psrm);
|
||||
HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index);
|
||||
HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width = 0, _In_opt_ UINT height = 0);
|
||||
HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p);
|
||||
BOOL GetEnumeratedFileName(
|
||||
__out_ecount(cchMax) PWSTR pszUniqueName,
|
||||
UINT cchMax,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "PowerRenameItem.h"
|
||||
#include "helpers.h"
|
||||
#include "icon_helpers.h"
|
||||
|
||||
int CPowerRenameItem::s_id = 0;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <algorithm>
|
||||
#include <shlobj.h>
|
||||
#include "helpers.h"
|
||||
#include "window_helpers.h"
|
||||
#include <filesystem>
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
@@ -192,6 +192,11 @@
|
||||
<ClCompile Include="PowerRenameRegExTests.cpp" />
|
||||
<ClCompile Include="TestFileHelper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\common\common.vcxproj">
|
||||
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
Binary file not shown.
@@ -225,16 +225,26 @@ export class GeneralSettings extends React.Component <any, any> {
|
||||
ref={(input) => {this.theme_reference=input;}}
|
||||
/>
|
||||
<Stack>
|
||||
<Label>Version {this.state.settings.general.powertoys_version}</Label>
|
||||
<PrimaryButton
|
||||
styles={{
|
||||
<Text variant='xLarge'>About PowerToys (Preview)</Text>
|
||||
<Label>Version {this.state.settings.general.powertoys_version}</Label>
|
||||
<PrimaryButton
|
||||
styles={{
|
||||
root: {
|
||||
alignSelf: "start"
|
||||
}
|
||||
}}
|
||||
href='https://github.com/microsoft/PowerToys/releases'
|
||||
target='_blank'
|
||||
>Check for updates</PrimaryButton>
|
||||
<Link
|
||||
href="https://github.com/microsoft/PowerToys#privacy-statement"
|
||||
target='_blank'
|
||||
styles = {{
|
||||
root: {
|
||||
alignSelf: "start"
|
||||
paddingTop: '10px'
|
||||
}
|
||||
}}
|
||||
href='https://github.com/microsoft/PowerToys/releases'
|
||||
target='_blank'
|
||||
>Check for updates</PrimaryButton>
|
||||
}}
|
||||
>Privacy statement</Link>
|
||||
</Stack>
|
||||
{/* An empty span to always give 30px padding in Edge. */}
|
||||
<span/>
|
||||
|
||||
2
src/settings/settings-html/dist/bundle.js
vendored
2
src/settings/settings-html/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user