/** * @file XTPControlComboBoxPopupBar.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/XTPColorManager.h" #include "Common/XTPHookManager.h" #include "Common/ScrollBar/XTPScrollInfo.h" #include "CommandBars/XTPCommandBarsDefines.h" #include "CommandBars/XTPPaintManager.h" #include "CommandBars/XTPControl.h" #include "CommandBars/XTPControlButton.h" #include "CommandBars/XTPControlPopup.h" #include "CommandBars/XTPCommandBar.h" #include "CommandBars/XTPPopupBar.h" #include "CommandBars/XTPControlEdit.h" #include "CommandBars/XTPControlComboBox.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ////////////////////////////////////////////////////////////////////////// // CXTPControlComboBoxPopupBar IMPLEMENT_XTP_COMMANDBAR(CXTPControlComboBoxPopupBar, CXTPPopupBar) CXTPControlComboBoxPopupBar::CXTPControlComboBoxPopupBar() { m_bComboBar = TRUE; m_bGrabFocus = FALSE; } BOOL CXTPControlComboBoxPopupBar::ProcessHookKeyDown(CXTPControlComboBox* pComboBox, UINT nChar, LPARAM lParam) { int nSel = GetCurSel(); if (pComboBox->GetEditCtrl()) { if ((GetKeyState(VK_MENU) >= 0) && (nChar == VK_UP || nChar == VK_DOWN || nChar == VK_PRIOR || nChar == VK_NEXT)) { CXTPCommandBar::OnHookKeyDown(nChar, lParam); if (nChar == VK_DOWN && nSel < (GetCount() - 1)) SetCurSel(nSel + 1); else if (nChar == VK_UP && nSel > 1) SetCurSel(nSel - 1); } else { return FALSE; } } else { if ((nChar == VK_F4 && GetKeyState(VK_MENU) >= 0) || ((nChar == VK_UP || nChar == VK_DOWN) && GetKeyState(VK_MENU) < 0)) { return FALSE; } else { CXTPCommandBar::OnHookKeyDown(nChar, lParam); } } if (nSel != GetCurSel()) { pComboBox->OnSelChanged(); if (pComboBox->GetEditCtrl()->GetSafeHwnd()) pComboBox->GetEditCtrl()->SetSel(0, -1); } return TRUE; } BOOL CXTPControlComboBoxPopupBar::OnHookKeyDown(UINT nChar, LPARAM lParam) { _ASSERTE(m_pControlPopup); CXTPControlComboBox* pComboBox = ((CXTPControlComboBox*)m_pControlPopup); if (!pComboBox) return CXTPCommandBar::OnHookKeyDown(nChar, lParam); if (nChar == VK_ESCAPE) { if (pComboBox->IsFocused()) return FALSE; return CXTPCommandBar::OnHookKeyDown(nChar, lParam); } if (nChar == VK_TAB) return FALSE; return ProcessHookKeyDown(pComboBox, nChar, lParam); }