Find all our projects in development below.
All source code is GNU General Public License (GPL)
Browsing frmHotkey.cs (1.39 KB)
using System;
using System.Windows.Forms;
namespace NvCplAdjust
{
public partial class frmHotkey : Form
{
private event callbackMethod m_callbackFunc;
public delegate void callbackMethod(Keys Hotkey, Keys HotkeyModifiers);
public frmHotkey(Keys Hotkey, Keys HotkeyModifiers, callbackMethod callbackFunc)
{
InitializeComponent();
hkProfile.Hotkey = Hotkey;
hkProfile.HotkeyModifiers = HotkeyModifiers;
m_callbackFunc = callbackFunc;
}
private void btnOK_Click(object sender, EventArgs e)
{
if (hkProfile.Hotkey == Keys.F12 && hkProfile.HotkeyModifiers == Keys.None)
{
MessageBox.Show("The F12 key without any modifiers is reserved for system use only and will not function properly.",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
hkProfile.Focus();
return;
}
if (m_callbackFunc != null)
{
// execute the callback method (if provided)
m_callbackFunc.Invoke(hkProfile.Hotkey, hkProfile.HotkeyModifiers);
}
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}