Substitute Tite bar for window
-
Hello I created a substitue title bar to replace the original title bar (gradient fill...) of Dialog or CMDIFrameWnd or CMDIChildWnd.First i remove the original titlebar of windows. Then i created a substitue window with style : WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN and i put this window as the same place as original title bar: RECT rcWnd; ::GetWindowRect(m_pParentWnd->m_hWnd, &rcWnd); // The m_pParentWnd is the CWnd of Dialog or // frame that i pass to this class. TITLEBARINFO tbi; tbi.cbSize = sizeof(TITLEBARINFO); ::GetTitleBarInfo(m_pParentWnd->m_hWnd, &tbi); RECT rcTitlebar = tbi.rcTitleBar; //Calculate the rect we need to create substitute // window for titlebar RECT rcSubstitute = {rcWnd.left, rcWnd.top, rcWnd.right, rcTitlebar.bottom}; //pszTitle is text on title bar //The CBMSTITLEBARDIALOG_CLASSNAME is already register before create window DWORD dwStyle = WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; BOOL bResult = CreateEx(WS_EX_TOOLWINDOW, CBMSTITLEBARDIALOG_CLASSNAME, pszWindowName, dwStyle, rcSubstitute.left, rcSubstitute.top, rcSubstitute.right - rcSubstitute.left, rcSubstitute.bottom - rcSubstitute.top, m_pParentWnd->m_hWnd, NULL, NULL ); If the parent window is CMDIFrameWnd or CMDIChildWnd, it's ok the substistute title bar is put the same place with the original titlebar and have these effects that i want. But with dialog the substistue title bar was wrong. (Not the same place with original title bar). ??? I think because the Dialog has WS_POPUP style, and the Substitue title bar that i create has the same WS_POPUP style. So it's wrong, is it right ? or some another reason. Please help me. Thanks