DwmExtendFrameIntoClientArea function
Applies to: desktop apps only
Extends the window frame into the client area.
Syntax
HRESULT WINAPI DwmExtendFrameIntoClientArea( HWND hWnd, __in const MARGINS *pMarInset );
Parameters
- hWnd
-
The handle to the window in which the frame will be extended into the client area.
- pMarInset [in]
-
A pointer to a MARGINS structure that describes the margins to use when extending the frame into the client area.
Return value
If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
This function must be called whenever Desktop Window Manager (DWM) composition is toggled. Handle the WM_DWMCOMPOSITIONCHANGED message for composition change notification.
Use negative margin values to create the "sheet of glass" effect where the client area is rendered as a solid surface with no window border.
Examples
The following sample demonstrates how to extend the bottom margin, creating a large bottom frame.
HRESULT ExtendIntoClientBottom(HWND hwnd)
{
// Set margins, extending the bottom margin
MARGINS margins = {0,0,0,25};
HRESULT hr = S_OK;
// Extend frame on the bottom of client area
hr = DwmExtendFrameIntoClientArea(hwnd,&margins);
if (SUCCEEDED(hr))
{
// ...
}
return hr;
}
The following sample demonstrates the "sheet of glass" effect where the client area is rendered without a window border.
HRESULT ExtendIntoClientAll(HWND hwnd)
{
// Negative margins have special meaning to DwmExtendFrameIntoClientArea.
// Negative margins create the "sheet of glass" effect, where the client area
// is rendered as a solid surface with no window border.
MARGINS margins = {-1};
HRESULT hr = S_OK;
// Extend the frame across the entire window.
hr = DwmExtendFrameIntoClientArea(hwnd,&margins);
if (SUCCEEDED(hr))
{
// ...
}
return hr;
}
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 2/14/2012
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 and a custom frame is used, 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. Note that the code in the examples should be changed accordingly, as well as the notice stating that only one value must be negative. Please see http://www.earth2me.com/development/dwm/ or 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);
[DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margin pMarInset);
- 5/20/2009
- dmex