public Form1() { InitializeComponent(); hook.KeyPressed += new EventHandler <KeyPressedEventArgs>(hook_KeyPressed); hook.RegisterHotKey(KBModifierKeys.Win, Keys.Z); MARGINS m = new MARGINS(); m.bottomHeight = -1; m.leftWidth = -1; m.rightWidth = -1; m.topHeight = -1; DwmExtendFrameIntoClientArea(Handle, ref m); //this.RecreateHandle(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { if (!DWM.DwmIsCompositionEnabled()) { DialogResult ret = MessageBox.Show("DWM is not enabled. Would you like to enable it?", "DWM is not enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ret == DialogResult.Yes) { DWM.DwmEnableComposition(true); if (!DWM.DwmIsCompositionEnabled()) { MessageBox.Show("DWM could not be enabled. This must be corrected before running this application.", "Problem changing system setting.", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } else { Application.Exit(); } } } catch (Exception ex) { MessageBox.Show("There was a problem with the Desktop Window Manager:\n\n" + ex.Message, "There was a problem with the DWM", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } try { hook = new KeyboardHook(); hook.KeyPressed += new EventHandler <KeyPressedEventArgs>(hook_KeyPressed); hook.RegisterHotKey(KBModifierKeys.Control | KBModifierKeys.Shift, Keys.Z); // No longer allowed as of Windows 8 //hook.RegisterHotKey(KBModifierKeys.Win | KBModifierKeys.Shift, Keys.Z); } catch (Exception ex) { MessageBox.Show("Could not register keyboard shortcut (Ctrl+Shift+Z):\n\n" + ex.Message, "There was a problem creating a keyboard shortcut", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } mnu = new ContextMenu(); _sep = new MenuItem("-"); _sep.Visible = false; mnu.MenuItems.Add(_sep); mnu.MenuItems.Add("&About", new EventHandler(mnuAbout_Click)); mnu.MenuItems.Add(new MenuItem("-")); mnu.MenuItems.Add("E&xit", new EventHandler(mnuExit_Click)); nicon = new NotifyIcon(); nicon.Visible = true; nicon.Icon = new System.Drawing.Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ThumbPreview.Resources.AppIcon.ico")); nicon.Text = "ThumbPreview"; nicon.ContextMenu = mnu; nicon.Click += new EventHandler(nicon_Click); Application.Run(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { if (!DWM.DwmIsCompositionEnabled()) { DialogResult ret = MessageBox.Show("DWM is not enabled. Would you like to enable it?", "DWM is not enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ret == DialogResult.Yes) { DWM.DwmEnableComposition(true); if (!DWM.DwmIsCompositionEnabled()) { MessageBox.Show("DWM could not be enabled. This must be corrected before running this application.", "Problem changing system setting.", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } else { Application.Exit(); } } } catch (Exception ex) { MessageBox.Show("There was a problem with the Desktop Window Manager:\n\n" + ex.Message, "There was a problem with the DWM", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } try { hook = new KeyboardHook(); hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(hook_KeyPressed); hook.RegisterHotKey(KBModifierKeys.Control | KBModifierKeys.Shift, Keys.Z); // No longer allowed as of Windows 8 //hook.RegisterHotKey(KBModifierKeys.Win | KBModifierKeys.Shift, Keys.Z); } catch (Exception ex) { MessageBox.Show("Could not register keyboard shortcut (Ctrl+Shift+Z):\n\n" + ex.Message, "There was a problem creating a keyboard shortcut", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } mnu = new ContextMenu(); _sep = new MenuItem("-"); _sep.Visible = false; mnu.MenuItems.Add(_sep); mnu.MenuItems.Add("&About", new EventHandler(mnuAbout_Click)); mnu.MenuItems.Add(new MenuItem("-")); mnu.MenuItems.Add("E&xit", new EventHandler(mnuExit_Click)); nicon = new NotifyIcon(); nicon.Visible = true; nicon.Icon = new System.Drawing.Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ThumbPreview.Resources.AppIcon.ico")); nicon.Text = "ThumbPreview"; nicon.ContextMenu = mnu; nicon.Click += new EventHandler(nicon_Click); Application.Run(); }