WPF Hwnd Adorner

28 בNovember 2014

This post is an introduction to a small WPF project I published. The project provides extended support for the HwndHost type, especially introducing a set of classes to support adornments over the hosted non-WPF child window. Introduction: The Win32 API provides the low-level infrastructure layer for Windows UI support. All UI frameworks running over Windows use this layer which is primarily defined in the user32 native dll. The most fundamental object in user32 is the well-known window Handle (hwnd). This window is a Windows user object which represents an area on the screen related to a running UI thread. Messages targeting the window like mouse actions performed over...

Switch On Type with dynamic C#

3 בNovember 2014

It is a very common scenario but still very annoying, you have a base class instance and you need to write code which deals with some specific derived classes, so, you try casting, check for null, and keep repeating the process until you finally resolve the actual type. This is a really uncomfortable pattern, since this iterative search cannot be reused in any way, hence you must repeat the whole code each time you need it. Here is a small example with the shortest code possible:public class Painter : ... { ... ...