Print Page | Close Window

CXTPControlComboBox and Sorting

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=2975
Printed Date: 04 October 2024 at 9:15am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPControlComboBox and Sorting
Posted By: precisionlaser
Subject: CXTPControlComboBox and Sorting
Date Posted: 29 September 2005 at 7:52pm
Does anyone know how to set the style for the CXTPControlComboBox so that it automatically sorts the contents a la a real combo box?  I just spent over $700 on this library and have wasted over an hour trying to figure out what ought to be a simple fix.  

Mark



Replies:
Posted By: Oleg
Date Posted: 30 September 2005 at 1:51am

Here fix:

class CControlSortedComboBoxList : public CXTPControlComboBoxList
{
 DECLARE_XTP_COMMANDBAR(CControlSortedComboBoxList);
public:

 virtual void CreateListBox()
 {
  CreateEx(WS_EX_STATICEDGE | WS_EX_TOOLWINDOW, _T("LISTBOX"), _T(""),
   LBS_SORT | WS_POPUP | WS_VSCROLL | WS_BORDER | WS_CLIPCHILDREN, CRect(0, 0, 0, 0), 0, 0);
 }

};


class CControlSortedComboBox: public CXTPControlComboBox
{
 DECLARE_XTP_CONTROL(CControlSortedComboBox)
public:

 CControlSortedComboBox()
 {
  if (m_pCommandBar)
  {
   m_pCommandBar->InternalRelease();
  }

  m_pCommandBar = new CControlSortedComboBoxList();
  ((CControlSortedComboBoxList*)m_pCommandBar)-> ;CreateListBox();
 }
};

...

IMPLEMENT_XTP_CONTROL(CControlSortedComboBox, CXTPControlComboBox)
IMPLEMENT_XTP_COMMANDBAR(CControlSortedComboBoxList, CXTPControlComboBoxList)

...

 

Usage:

   CControlSortedComboBox* pComboFind = new CControlSortedComboBox;

   pComboFind->SetDropDownListStyle();
   pComboFind->SetEditHint(_T("Click to find string"));

   pComboFind->AddString(_T("Line1"));
   pComboFind->AddString(_T("Line3"));
   pComboFind->AddString(_T("Line2"));

   pComboFind->SetWidth(150);
   pComboFind->SetCaption(_T("Find"));
   pComboFind->SetStyle(xtpComboLabel);

   lpCreateControl->pControl = pComboFind;
   return TRUE;

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: precisionlaser
Date Posted: 30 September 2005 at 5:52am
Thank you, Oleg...I was afraid that was the only way to do this.  I ended up just adding the LBS_SORT style to the CXTPControlComobBox class in the CreateListBox function and rebuilding.  I almost never use a combo box without auto sorting, so it's easier just to do it this way and if I have to derive a new class without sorting, I'll just do it then.  Why not a SetSortStyle member function in the future?

Mark


Posted By: Oleg
Date Posted: 30 September 2005 at 11:47am

Added for next, release.

To prevent fixing your application for next release,

I recommend change it back and to add:

void ModifyListBoxStyle(DWORD dwRemove, DWORD dwAdd)

void CXTPControlComboBox::ModifyListBoxStyle(DWORD dwRemove, DWORD dwAdd)
{
 if (IsValidList())
 { 
  CXTPControlComboBoxList* pComboBoxList = ((CXTPControlComboBoxList*)m_pCommandBar);
  
  pComboBoxList->m_dwStyle |= dwAdd;
  pComboBoxList->m_dwStyle &= ~dwRemove;

  pComboBoxList->DestroyWindow();
  pComboBoxList->CreateListBox();
 }
}

 

And to fix CreateListBox as

void CXTPControlComboBoxList::CreateListBox()
{
 CreateEx(WS_EX_STATICEDGE | WS_EX_TOOLWINDOW, _T("LISTBOX"), _T(""),
  WS_POPUP | WS_VSCROLL | WS_BORDER | WS_CLIPCHILDREN | m_dwStyle, CRect(0, 0, 0, 0), 0, 0);
}

Usage:

 

   CXTPControlComboBox* pComboFind = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  pComboFind->ModifyListBoxStyle(0, LBS_SORT);

   pComboFind->SetDropDownListStyle();
   pComboFind->SetEditHint(_T("Click to find string"));

   pComboFind->AddString(_T("Line1"));
   pComboFind->AddString(_T("Line3"));
   pComboFind->AddString(_T("Line2"));



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: csturg
Date Posted: 05 October 2005 at 2:57pm

Any idea when a version will be released that contains this sorting change?

Thanks, Craig




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net