tags

windows forms

[WPF] Declare global hotkeys in XAML with NHotkey

A common requirement for desktop applications is to handle system-wide hotkeys, in order to intercept keyboard shortcuts even when they don’t have focus. Unfortunately, there is no built-in feature in the .NET framework to do it. Of course, this is not a new issue, and there are quite a few open-source libraries that address it (e.g. VirtualInput). Most of them rely on a global system hook, which allow them to intercept all keystrokes, even the ones you’re not interested in.

[Windows Forms] Automatically drag and drop controls (DragMove)

Here’s a piece of code I wrote a while ago, I just thought it could be useful for WinForms developers… In WPF, there is a very handy method to move a window with no borders : Window.DragMove. It can be used like that : private void Window_MouseDown(object sender, MouseButtonEventArgs e) { this.DragMove(); } When you call this method, the window is moved with the mouse until the button is released. It could hardly be simpler ;)