/** * @file XTPResizeGroupBox.cpp * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #include "stdafx.h" #include "Common/XTPTypeId.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Common/XTPSynchro.h" #include "Common/XTPApplication.h" #include "Common/XTPSingleton.h" #include "Common/XTPGdiObjects.h" #include "Common/XTPDrawHelpers.h" #include "Controls/Util/XTPControlTheme.h" #include "Controls/Defines.h" #include "Controls/Button/XTPButton.h" #include "Controls/Resize/XTPResizeGroupBox.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CXTPResizeGroupBox CXTPResizeGroupBox::CXTPResizeGroupBox() { } CXTPResizeGroupBox::~CXTPResizeGroupBox() { } IMPLEMENT_DYNAMIC(CXTPResizeGroupBox, CXTPButton) #include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_MESSAGE_MAP(CXTPResizeGroupBox, CXTPButton) //{{AFX_MSG_MAP(CXTPResizeGroupBox) // ON_WM_ERASEBKGND() ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() #include "Common/Base/Diagnostic/XTPEndAfxMap.h" ///////////////////////////////////////////////////////////////////////////// // CXTPResizeGroupBox message handlers void CXTPResizeGroupBox::Exclude(CDC* pDC, CRect& rcClient) { // get a pointer to the parent. CWnd* pWndParent = GetParent(); if (!pWndParent) return; // get a pointer to the parents first child. CWnd* pWnd = pWndParent->GetWindow(GW_CHILD); if (pWnd == NULL) return; // iterate thru all children and exclude those children that // are located inside the group box. CWnd* pChildWnd = pWnd->GetWindow(GW_HWNDFIRST); while (pChildWnd != NULL) { // make sure we do not exclude ourself if (pChildWnd != this && pChildWnd->IsWindowVisible()) { CRect rc; pChildWnd->GetWindowRect(&rc); ScreenToClient(&rc); // if the parent's child is located in our group box, exclude // it from painting. if (rcClient.PtInRect(rc.TopLeft()) || rcClient.PtInRect(rc.BottomRight())) { pDC->ExcludeClipRect(&rc); } } pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); } } BOOL CXTPResizeGroupBox::OnEraseBkgnd(CDC* /*pDC*/) { return TRUE; } void CXTPResizeGroupBox::OnPaint() { CPaintDC dc(this); // get the client area size. CRect rcClient; GetClientRect(&rcClient); // exclude controls that we "group" Exclude(&dc, rcClient); // Paint to a memory device context to help // eliminate screen flicker. CXTPBufferDC memDC(dc); HBRUSH hBrush = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORBTN, (WPARAM)memDC.GetSafeHdc(), (LRESULT)m_hWnd); if (hBrush) { ::FillRect(memDC, rcClient, hBrush); } else { memDC.FillSolidRect(rcClient, GetSysColor(COLOR_3DFACE)); } // Let the window do its default painting... // CXTPButton::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0); CXTPButton::OnDraw(&memDC); }