728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Import
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 시스템 메뉴 구하기 - GetSystemMenu(windowHandle, revert)
/// <summary>
/// 시스템 메뉴 구하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="revert">복구 여부</param>
/// <returns>처리 결과</returns>
[DllImport("user32")]
private static extern IntPtr GetSystemMenu(IntPtr windowHandle, bool revert);
#endregion
#region 메뉴 항목 활성화하기 - EnableMenuItem(menuHandle, menuItemID, enable)
/// <summary>
/// 메뉴 항목 활성화하기
/// </summary>
/// <param name="menuHandle">메뉴 핸들</param>
/// <param name="menuItemID">메뉴 항목 ID</param>
/// <param name="enable">활성화 여부</param>
/// <returns>처리 결과</returns>
[DllImport("user32")]
private static extern int EnableMenuItem(IntPtr menuHandle, int menuItemID, int enable);
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.disableButton.Click += disableButton_Click;
this.enableButton.Click += enableButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 메뉴 비활성화 버튼 클릭시 처리하기 - disableButton_Click(sender, e)
/// <summary>
/// 메뉴 비활성화 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void disableButton_Click(object sender, EventArgs e)
{
IntPtr menuHandle = GetSystemMenu(Handle, false);
EnableMenuItem(menuHandle, 0xF060, 0x1);
}
#endregion
#region 메뉴 활성화 버튼 클릭시 처리하기 - enableButton_Click(sender, e)
/// <summary>
/// 메뉴 활성화 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void enableButton_Click(object sender, EventArgs e)
{
IntPtr menuHandle = GetSystemMenu(Handle, true);
EnableMenuItem(menuHandle, 0xF060, 0x1);
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WIN32' 카테고리의 다른 글
[C#/WIN32] LoadLibrary API 함수 선언하기 (0) | 2020.12.25 |
---|---|
[C#/WIN32] CreateRemoteThread API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] WriteProcessMemory API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] VirtualAllocEx API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] GetModuleHandle API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] OpenProcess API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] GetLastError API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] SetWindowDisplayAffinity API 함수 : 화면 캡처 방지하기 (0) | 2020.05.20 |
[C#/WIN32/.NET6] SendARP API 함수 : MAC 주소 구하기 (0) | 2019.08.16 |
[C#/WIN32] ExitWindowsEx API 함수 : 윈도우즈 종료하기/재부팅하기/로그오프하기 (0) | 2017.02.28 |
댓글을 달아 주세요