Partager via


CWindow::ModifyStyle

Modifies the window styles of the CWindow object.

BOOL ModifyStyle( 
   DWORD dwRemove, 
   DWORD dwAdd, 
   UINT nFlags = 0  
) throw();

Parameters

  • dwRemove
    [in] Specifies the window styles to be removed during style modification.

  • dwAdd
    [in] Specifies the window styles to be added during style modification.

  • nFlags
    [in] Window-positioning flags. For a list of possible values, see the SetWindowPos function in the Windows SDK.

Return Value

TRUE if the window styles are modified; otherwise, FALSE.

Remarks

Styles to be added or removed can be combined by using the bitwise OR ( | ) operator. See the CreateWindow function in the Windows SDK* *for information about the available window styles.

If nFlags is nonzero, ModifyStyle calls the Win32 function SetWindowPos, and redraws the window by combining nFlags with the following four flags:

  • SWP_NOSIZE   Retains the current size.

  • SWP_NOMOVE   Retains the current position.

  • SWP_NOZORDER   Retains the current Z order.

  • SWP_NOACTIVATE   Does not activate the window.

To modify a window's extended styles, call ModifyStyleEx.

Example

//The following example attaches an HWND to the CWindow object and  
//calls CWindow::ModifyStyle() to add and remove the window styles

CWindow myWindow;
myWindow.Attach(hWnd);

//The following line removes the WS_CLIPCHILDREN style from the  
//window and adds the WS_CAPTION style to the window
myWindow.ModifyStyle(WS_CLIPCHILDREN, WS_CAPTION);

Requirements

Header: atlwin.h

See Also

Reference

CWindow Class

CWindow::GetStyle