Skip to content

Commit ebf7e1c

Browse files
committed
Added the possibility to maximize a window (#7)
1 parent b590074 commit ebf7e1c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

PermaTop/UserControls/WindowPropertyItem.xaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ColumnDefinition Width="Auto"/>
1919
<ColumnDefinition Width="Auto"/>
2020
<ColumnDefinition Width="Auto"/>
21+
<ColumnDefinition Width="Auto"/>
2122
</Grid.ColumnDefinitions>
2223
<TextBlock x:Name="TitleTxt" FontWeight="ExtraBold" d:Text="WindowTItle" FontSize="14" VerticalAlignment="Center">
2324
<TextBlock.ToolTip>
@@ -26,7 +27,8 @@
2627
</TextBlock>
2728
<Button Foreground="{DynamicResource Foreground1}" x:Name="FavBtn" Click="FavBtn_Click" Width="30" Grid.Column="2" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF710;" FontSize="14" Margin="0 0 5 0"/>
2829
<Button Foreground="{DynamicResource Foreground1}" x:Name="PinBtn" Click="PinBtn_Click" Width="30" Grid.Column="3" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF602;" FontSize="14" Margin="0 0 5 0"/>
29-
<Button Foreground="{DynamicResource Foreground1}" x:Name="CloseBtn" Click="CloseBtn_Click" Width="30" Grid.Column="4" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF36A;" FontSize="14"/>
30+
<Button Foreground="{DynamicResource Foreground1}" x:Name="MaxRestoreBtn" Click="MaxRestoreBtn_Click" Width="30" Grid.Column="4" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xFA41;" FontSize="14" Margin="0 0 5 0"/>
31+
<Button Foreground="{DynamicResource Foreground1}" x:Name="CloseBtn" Click="CloseBtn_Click" Width="30" Grid.Column="5" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF36A;" FontSize="14"/>
3032
</Grid>
3133
</Border>
3234
</UserControl>

PermaTop/UserControls/WindowPropertyItem.xaml.cs

+12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ private void FavBtn_Click(object sender, RoutedEventArgs e)
8282

8383
private const int WM_SYSCOMMAND = 0x0112;
8484
private const int SC_CLOSE = 0xF060;
85+
private const int SC_MAXIMIZE = 0xF030;
86+
8587

8688
[DllImport("user32.dll")]
8789
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
@@ -94,4 +96,14 @@ private void CloseBtn_Click(object sender, RoutedEventArgs e)
9496
}
9597
catch { }
9698
}
99+
100+
private void MaxRestoreBtn_Click(object sender, RoutedEventArgs e)
101+
{
102+
if (!Global.IsWindowMaximized(WindowInfo.Hwnd))
103+
{
104+
SendMessage(WindowInfo.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_MAXIMIZE, IntPtr.Zero);
105+
106+
return;
107+
}
108+
}
97109
}

0 commit comments

Comments
 (0)