An HWND is the base data stucture in the Windows API for the majority of the on-screen objects. It is Hungarian Notation for a "Handle to a Window". It inherits handle logic like other structures such as a the more generic HANDLE, and is thus operated on by the basic handle operations in Windows, such as DuplicateHandle(), and CloseHandle().

The HWND structure is really a pointer to a struct of type _HWND with a single visible member called unused. When you open up anything with an HWND in a JIT debugger, you'll notice that the unused section, even if you zero out the memory, is rarely "unused". I think it is just not talked about so people are not tempted to mess with it.

What is neat about having a single abstraction is that you can get an hWnd object for almost anything onscreen other than a GDI object. Simply put, everything in Windows is a window, in a sense. A button is the same abstracted type as a checkbox, or the window frame itself, or an MDI child window, or any other type of control. Certain flavors (think styles, in a windows sense) of HWNDs are subject to certain special operations... ie: IsDlgButtonChecked() is not going to return a non-erroneous value on a handle to a menu item.

Log in or registerto write something here or to contact authors.