최대화 버튼 비활성화
MainWindow.xaml
<Window
x:Class="SampleApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SampleApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="300"
Height="200"
ResizeMode="CanResizeWithGrip"
SourceInitialized="Window_SourceInitialized"
mc:Ignorable="d">
<Grid />
</Window>
MainWindow.xaml.cs
using System;
using System.Runtime.InteropServices;
using System.Windows;
namespace SampleApp
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// ウィンドウに関するデータを取得
/// </summary>
/// <param name="hWnd"></param>
/// <param name="nIndex"></param>
/// <returns></returns>
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
/// <summary>
/// ウィンドウの属性を変更
/// </summary>
/// <param name="hWnd"></param>
/// <param name="nIndex"></param>
/// <param name="dwNewLong"></param>
/// <returns></returns>
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
/// <summary>
/// ウィンドウスタイル
/// </summary>
private const int GWL_STYLE = -16;
/// <summary>
/// 最大化ボタン
/// </summary>
private const int WS_MAXIMIZEBOX = 0x0001_0000; // C#7より前の場合は 0x00010000
public MainWindow()
{
InitializeComponent();
}
/// <summary>
/// 初期化時
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_SourceInitialized(object sender, EventArgs e)
{
IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper((Window)sender).Handle;
int value = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, (int)(value & ~WS_MAXIMIZEBOX));
}
}
}
Reference
이 문제에 관하여(최대화 버튼 비활성화), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Kosen-amai/items/d7de36443b33a7e5cb3c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)