// DialogSampleDlg.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "DialogSampleDlg.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDialogSampleDlg dialog CDialogSampleDlg::CDialogSampleDlg(CWnd* pParent /*=NULL*/) : CDialogSampleDlgBase(CDialogSampleDlg::IDD, pParent) { //{{AFX_DATA_INIT(CDialogSampleDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_rcBorders.SetRectEmpty(); m_bInRepositionControls = FALSE; m_bInitDone = FALSE; } void CDialogSampleDlg::DoDataExchange(CDataExchange* pDX) { CDialogSampleDlgBase::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDialogSampleDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDialogSampleDlg, CDialogSampleDlgBase) //{{AFX_MSG_MAP(CDialogSampleDlg) ON_WM_SIZE() ON_COMMAND_RANGE(ID_BUTTON_BACKWARD, ID_BUTTON_REC, OnEmptyCommandRange) ON_WM_CTLCOLOR() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CDialogSampleDlg message handlers BOOL CDialogSampleDlg::OnInitDialog() { #ifdef _XTP_INCLUDE_CONTROLS SetFlag(xtpResizeNoSizeIcon); #endif CDialogSampleDlgBase::OnInitDialog(); VERIFY(InitCommandBars()); // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create } #ifndef _XTP_INCLUDE_CONTROLS ModifyStyle(WS_THICKFRAME, DS_MODALFRAME); #endif if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } pCommandBars->SetMenu(_T("Menu Bar"), IDR_DIALOGSAMPLE); CXTPToolBar* pToolBar = pCommandBars->Add(_T("Multimedia"), xtpBarTop); if ((!pToolBar) || (!pToolBar->LoadToolBar(IDR_MM_TOOLBAR, FALSE))) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } CXTPImageManager* pImgMgr = pCommandBars->GetImageManager(); if (pImgMgr) { CString type(_T("RT_XAML")); // resource type UINT nWidth = 0; nWidth = XTP_DPI_X(16); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_PLAY_BACKWARD, ID_BUTTON_BACKWARD, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_PLAY_FORWARD, ID_BUTTON_FORWARD, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_PLAY, ID_BUTTON_PLAY, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_STOP, ID_BUTTON_STOP, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_PAUSE, ID_BUTTON_PAUSE, nWidth); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_NORMAL_MEDIA_RECORD, ID_BUTTON_REC, nWidth); nWidth = XTP_DPI_X(16); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_PLAY_BACKWARD, ID_BUTTON_BACKWARD, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_PLAY_FORWARD, ID_BUTTON_FORWARD, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_PLAY, ID_BUTTON_PLAY, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_STOP, ID_BUTTON_STOP, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_PAUSE, ID_BUTTON_PAUSE, nWidth, xtpImageDisabled); pImgMgr->SetVectorIcon(type, IDR_XAML_SMALL_ICON_DISABLED_MEDIA_RECORD, ID_BUTTON_REC, nWidth, xtpImageDisabled); } ((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BUTTON_PLAY, TRUE, FALSE)) ->SetStyle(xtpButtonIconAndCaption); ((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BUTTON_STOP, TRUE, FALSE)) ->SetStyle(xtpButtonIconAndCaption); ((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BUTTON_PAUSE, TRUE, FALSE)) ->SetStyle(xtpButtonIconAndCaption); m_wndStatusBar.SetCommandBars(pCommandBars); m_wndStatusBar.SetPaneInfo(0, ID_SEPARATOR, SBPS_STRETCH, 100); #ifdef _XTP_INCLUDE_CONTROLS SetResize(IDC_SLIDER1, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDC_STATIC_POSITION, XTP_ANCHOR_TOPLEFT, CXTPResizePoint(0.3f, 1)); SetResize(IDC_STATIC_RECT, CXTPResizePoint(0.3f, 0), CXTPResizePoint(0.6f, 1)); SetResize(IDC_STATIC_LENGTH, CXTPResizePoint(0.6f, 0), CXTPResizePoint(1, 1)); #endif m_bInitDone = TRUE; RepositionControls(); #ifdef _XTP_INCLUDE_CONTROLS m_szMin = m_szWindow; #endif switch (m_Theme) { case xtpThemeDlgOffice2007: case xtpThemeDlgOffice2010: case xtpThemeDlgOffice2013: case xtpThemeDlgOffice2016: case xtpThemeDlgVisualStudio2012: case xtpThemeDlgVisualStudio2015: case xtpThemeDlgVisualStudio2017: case xtpThemeDlgVisualStudio2019: case xtpThemeDlgVisualStudio2022: case xtpThemeDlgNativeWindows: case xtpThemeDlgNativeWindows10: case xtpThemeDlgNativeWindows11: GetCommandBars()->EnableFrameTheme(TRUE); break; default: GetCommandBars()->EnableFrameTheme(NULL); break; } GetCommandBars()->RedrawCommandBars(); return TRUE; // return TRUE unless you set the focus to a control } void CDialogSampleDlg::RepositionControls() { if (m_bInRepositionControls || !m_bInitDone) return; CRect rcClientStart; CRect rcClientNow; GetClientRect(rcClientStart); if ((GetStyle() & WS_MINIMIZE) || (rcClientStart.IsRectEmpty())) return; m_bInRepositionControls = TRUE; RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow); CRect rcBorders(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top, rcClientStart.right - rcClientNow.right, rcClientStart.bottom - rcClientNow.bottom); if (rcBorders != m_rcBorders) { CPoint ptOffset(rcBorders.left - m_rcBorders.left, rcBorders.top - m_rcBorders.top); CSize szOffset(rcBorders.left + rcBorders.right - m_rcBorders.left - m_rcBorders.right, rcBorders.top + rcBorders.bottom - m_rcBorders.top - m_rcBorders.bottom); CRect rcWindow; GetWindowRect(rcWindow); rcWindow.BottomRight() += szOffset; #ifndef _XTP_INCLUDE_CONTROLS CRect rcChild; CWnd* pwndChild = GetWindow(GW_CHILD); while (pwndChild) { pwndChild->GetWindowRect(rcChild); ScreenToClient(&rcChild); rcChild.OffsetRect(ptOffset); pwndChild->MoveWindow(rcChild, TRUE); pwndChild->Invalidate(FALSE); pwndChild = pwndChild->GetNextWindow(); } #else Offset(ptOffset); m_szWindow += szOffset; m_szMin += szOffset; #endif MoveWindow(rcWindow, TRUE); } m_rcBorders = rcBorders; RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); m_bInRepositionControls = FALSE; } void CDialogSampleDlg::OnSize(UINT nType, int cx, int cy) { CDialogSampleDlgBase::OnSize(nType, cx, cy); RepositionControls(); } void CDialogSampleDlg::OnEmptyCommandRange(UINT) { } HBRUSH CDialogSampleDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_STATIC) { pDC->SetTextColor(m_clrText); pDC->SetBkMode(TRANSPARENT); } return m_brush; } void CDialogSampleDlg::RefreshMetrics() { m_brush.DeleteObject(); COLORREF clrBrush = ::GetSysColor(COLOR_3DFACE); m_clrText = RGB(0, 0, 0); switch (m_Theme) { case xtpThemeDlgVisualStudio2008: case xtpThemeDlgVisualStudio2010: case xtpThemeDlgOffice2003: case xtpThemeDlgOffice2007: case xtpThemeDlgOffice2010: clrBrush = XTPIniColor(_T("Toolbar"), _T("DockBarFace"), RGB(255, 255, 255)); m_clrText = XTPIniColor(_T("Toolbar"), _T("MenuBarText"), RGB(255, 255, 255)); break; case xtpThemeDlgOffice2013: case xtpThemeDlgOffice2016: case xtpThemeDlgVisualStudio2012: case xtpThemeDlgVisualStudio2015: case xtpThemeDlgVisualStudio2017: case xtpThemeDlgVisualStudio2019: case xtpThemeDlgVisualStudio2022: case xtpThemeDlgNativeWindows10: case xtpThemeDlgNativeWindows11: clrBrush = XTPIniColor(_T("CommandBars"), _T("Back"), RGB(255, 255, 255)); m_clrText = XTPIniColor(_T("CommandBars.Menu"), _T("ButtonText"), RGB(255, 255, 255)); break; default: break; } m_brush.CreateSolidBrush(clrBrush); }