728x90
반응형
728x170
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="Window 클래스 : 시스템 메뉴 숨기기"
FontFamily="나눔고딕코딩"
FontSize="16">
</Window>
728x90
▶ MainWindow.xaml.cs
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Import
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 윈도우 상태 구하기 - GetWindowLong(windowHandle, index)
/// <summary>
/// 윈도우 상태 구하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="index">인덱스</param>
/// <returns>윈도우 상태</returns>
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr windowHandle, int index);
#endregion
#region 윈도우 상태 설정하기 - SetWindowLong(windowHandle, index, state)
/// <summary>
/// 윈도우 상태 설정하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="index">인덱스</param>
/// <param name="state">윈도우 상태</param>
/// <returns>처리 결과</returns>
[DllImport("user32")]
private static extern int SetWindowLong(IntPtr windowHandle, int index, int state);
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// GWL_STYLE
/// </summary>
private const int GWL_STYLE = -16;
/// <summary>
/// WS_SYSMENU
/// </summary>
private const int WS_SYSMENU = 0x00080000;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
Loaded += Window_Loaded;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 윈도우 로드시 처리하기 - Window_Loaded(sender, e)
/// <summary>
/// 윈도우 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
HideSystemMenu(this);
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Function
#region 윈도우 객체 핸들 구하기 - GetWindowHandle(window)
/// <summary>
/// 윈도우 객체 핸들 구하기
/// </summary>
/// <param name="window">윈도우</param>
/// <returns>윈도우 객체 핸들</returns>
private IntPtr GetWindowHandle(Window window)
{
return new WindowInteropHelper(window).Handle;
}
#endregion
#region 시스템 메뉴 숨기기 - HideSystemMenu(window)
/// <summary>
/// 시스템 메뉴 숨기기
/// </summary>
/// <param name="window">윈도우</param>
private void HideSystemMenu(Window window)
{
IntPtr windowHandle = GetWindowHandle(window);
int state = GetWindowLong(windowHandle, GWL_STYLE);
state = state ^ WS_SYSMENU;
SetWindowLong(windowHandle, GWL_STYLE, state);
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] BitmapSource 클래스 : TIFF 파일 저장하기 (0) | 2014.02.21 |
---|---|
[C#/WPF] BitmapSource 클래스 : PNG 파일 저장하기 (0) | 2014.02.21 |
[C#/WPF] 픽셀 스냅(Pixel Snap) 사용하기 (0) | 2014.02.21 |
[C#/WPF] GridViewColumn 클래스 : 바인딩 설정하기 (0) | 2014.02.21 |
[C#/WPF] Window 클래스 : 윈도우 객체 핸들 구하기 (0) | 2014.02.21 |
[C#/WPF] Dispatcher 클래스 : Invoke 메소드를 사용해 크로스 스레드(Cross Thread) 처리하기 (0) | 2014.02.21 |
[C#/WPF] ASCII ART 문자열 구하기 (0) | 2014.02.21 |
[C#/WPF] SolidColorBrush 클래스 : 디폴트 시스템 색상 오버라이딩 하기 (0) | 2014.02.20 |
[C#/WPF] Ellipse 엘리먼트 : 커졌다 사라지는 동심원 애니메이션 설정하기 (0) | 2014.02.20 |
[C#/WPF] BitmapSource 클래스 : WINFORM Icon 객체에서 비트맵 소스 구하기 (0) | 2014.02.20 |
댓글을 달아 주세요