Sub-classing techniques

Once we understand the previous architecture, it makes sense to use it in a variety of ways: avoiding predefined behaviors for controls or windows, adding specific elements to existing windows components, and many others.

Let's try a basic example. Suppose that we want to change the way a window responds to the left button. Only that. So, we have a simple Windows Forms application, and we need to think of the elements we need in order to code that behavior.

First, we need to capture the specific messages addressed to the left button. Then, we have the override to WndProc associated with our window, determine what to do if the message is the one required, and finally, always return the control to the operating system correctly. ...

Get Mastering C# and .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.