Esempio n. 1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            HotKetID = HotKeyHelpper.GlobalAddAtom("SimpleScreenshot-HotKey");

            Debug.WriteLine($"FormMain_Load:HotKetID={HotKetID}");

            HotKeyHelpper.KeyModifiers keyModifiers
                = (Settings.Default.HotKey_Ctrl ? HotKeyHelpper.KeyModifiers.Ctrl : HotKeyHelpper.KeyModifiers.None)
                  | (Settings.Default.HotKey_Shift ? HotKeyHelpper.KeyModifiers.Shift : HotKeyHelpper.KeyModifiers.None)
                  | (Settings.Default.HotKey_Alt ? HotKeyHelpper.KeyModifiers.Alt : HotKeyHelpper.KeyModifiers.None);

            var result = HotKeyHelpper.RegisterHotKey(this.Handle, HotKetID, keyModifiers, Settings.Default.HotKey_KeyValue);

            if (result == false)
            {
                MessageBox.Show("热键冲突,请修改热键。", "Simple Screenshot");
            }
            else
            {
                new FormStartOK().ShowDialog();
            }

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
            SetStyle(ControlStyles.DoubleBuffer, true);         // 双缓冲

            this.Visible = false;
        }
Esempio n. 2
0
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     HotKeyHelpper.UnregisterHotKey(this.Handle, HotKetID);
     HotKeyHelpper.GlobalDeleteAtom(HotKetID);
 }