Export (0) Print
Expand All

NativeWindow.OnHandleChange Method

Specifies a notification method that is called when the handle for a window is changed.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

protected function OnHandleChange()

This method is invoked when the value of the Handle property has changed.

Notes to Inheritors:

Override this method to track changes that are made to the window handle.

The following code example demonstrates creating a window with a specific operating system window class name. The example creates a class that inherits from NativeWindow to accomplish this. The example also demonstrates overriding the OnHandleChange method to be notified when the Handle changes.

The MyNativeWindow class creates a new window with the ClassName set to BUTTON. This creates a Win32 button window. The location and size of the button is set, along with specifying additional window styles. The class demonstrates how to use the CreateHandle method and override the WndProc method to intercept window messages that are received. Although the example looks for the WM_ACTIVATEAPP message, this can be replaced in a real program with window messages specific to the type created.

This code is an excerpt from the example shown in the NativeWindow class overview. Some code is not shown for the purpose of brevity. See NativeWindow for the whole code listing.

NoteNote:

Some control types send their window messages to the window parent instead of the window. See the Windows Platform SDK for more information.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft