[C#] WinForm 시스템 메뉴에 나만의 메뉴 추가하기

CSharp
using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace CaptionTimetableSupporet { public partial class MainForm : Form { // P/Invoke constants private const int WM_SYSCOMMAND = 0x112; private const int MF_STRING = 0x0; private const int MF_SEPARATOR = 0x800; // P/Invoke declarations [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern bool AppendMenu(IntPtr hMenu, int uFlags, int uIDNewItem, string lpNewItem); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern bool InsertMenu(IntPtr hMenu, int uPosition, int uFlags, int uIDNewItem, string lpNewItem); // ID for the About item on the system menu private int SYSMENU_ABOUT_ID = 0x1; protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); // Get a handle to a copy of this form's system (window) menu…
Read More