Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CXTPControlComboBox and Sorting
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPControlComboBox and Sorting

 Post Reply Post Reply
Author
Message
precisionlaser View Drop Down
Newbie
Newbie


Joined: 29 September 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote precisionlaser Quote  Post ReplyReply Direct Link To This Post Topic: CXTPControlComboBox and Sorting
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
precisionlaser View Drop Down
Newbie
Newbie


Joined: 29 September 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote precisionlaser Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
csturg View Drop Down
Newbie
Newbie


Joined: 13 July 2005
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote csturg Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2005 at 2:57pm

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

Thanks, Craig

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.