This topic has not yet been rated - Rate this topic

DwmDefWindowProc function

Applies to: desktop apps only

Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area.

Syntax

BOOL WINAPI DwmDefWindowProc(
  __in   HWND hwnd,
  __in   UINT msg,
  __in   WPARAM wParam,
  __in   LPARAM lParam,
  __out  LRESULT *plResult
);

Parameters

hwnd [in]

A handle to the window procedure that received the message.

msg [in]

The message.

wParam [in]

Specifies additional message information. The content of this parameter depends on the value of the msg parameter.

lParam [in]

Specifies additional message information. The content of this parameter depends on the value of the msg parameter.

plResult [out]

A pointer to an LRESULT value that, when this method returns successfully,receives the result of the hit test.

Return value

TRUE if DwmDefWindowProc handled the message; otherwise, FALSE.

Remarks

When creating custom frames that include the standard caption buttons, WM_NCHITTEST and other non-client hit test messages should first be passed to the DwmDefWindowProc function. This enables the DWM to provide hit testing for the captions buttons. If DwmDefWindowProc does not handle the non-client hit test messages, further processing of these messages might be neccessary.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Dwmapi.h

Library

Dwmapi.lib

DLL

Dwmapi.dll

 

 

Send comments about this topic to Microsoft

Build date: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Bug Warning

Note that if you want to extend the glass to fill the entire client area, you MUST specify -1 for ALL properties, not just the first; otherwise, DwmDefWindowProc will not function correctly.  When 0 is specified as the top value for DwmExtendFrameIntoClientArea, DwmDefWindowProc will not recognize the caption buttons, and DefWindowProc will default to Windows NT-style caption buttons, creating various interface problems.  This indicates that various portions of the DWM API test only single property of the inset margin for negative values, rather than all four, as documented.  As such, the sign of all properties should be consistent.  If one property is negative, all four MUST be negative, or different functions will handle the frame/client boundary differently.  Please see http://www.earth2me.com/development/dwm/ for more information.

Incorrect:

MARGINS mgMarInset = { -1 }; // Will not work: translates to { -1, 0, 0, 0 }
DwmExtendFrameIntoClientArea(hWnd, &mgMarInset);


Correct:
MARGINS mgMarInset = { -1, -1, -1, -1 }; // Correct
DwmExtendFrameIntoClientArea(hWnd, &mgMarInset);

C# syntax
[DllImport("dwmapi.dll")]
public static extern int DwmDefWindowProc(IntPtr hwnd, ushort msg, long wParam, long lParam, out int plResult);
vb.net syntax
<DllImport("dwmapi.dll")> _
Public Shared Function DwmDefWindowProc(ByVal hwnd As IntPtr, ByVal msg As UInt16, ByVal wParam As Long, ByVal lParam As Long, <Out> ByRef plResult As Integer) As Integer
End Function