Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Problem creating CExtShellComboBox inside CExtWA Collapse All
Subject Author Date
Chris G. Jul 30, 2009 - 7:01 PM

Hello Prof-UIS,


i have problems creating a CExtShellComboBox and a CExtNCSB<CExtShellListCtrl> instance in my CExtWA<CExtControlBar> derived control bar. The following three problems occured:



  1. Clicking inside the shell combobox leads to an assertion at extcombobox.cpp (line 234).

  2. The shell combobox control ignores the rectangle specified in the create method.

  3. Invoking the create method for the CExtNCSB<CExtShellListCtrl> instance leads to an assertion at wincore.cpp (line 329)


I’m stuck with this problems because the Prof-UIS Controls sample doesn’t seem to have them and there doesn’t seem to be a generall difference in how the sample creates the controls except for creating them in a resizable dialog.


Here is the source:


// Header file:


class CFileBrowser : public CExtWA<CExtControlBar>

{

    DECLARE_DYNAMIC(CFileBrowser)



public:

    CExtShellComboBox            m_wndShellCombo;

    CExtNCSB<CExtShellListCtrl>    m_wndShellList;



public:

    CFileBrowser();

    virtual ~CFileBrowser();

    virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);



protected:

    DECLARE_MESSAGE_MAP()

public:

    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

};


 


// Source file:


IMPLEMENT_DYNAMIC(CFileBrowser, CExtWA<CExtControlBar>)



CFileBrowser::CFileBrowser()

{

}



CFileBrowser::~CFileBrowser()

{

}



BEGIN_MESSAGE_MAP(CFileBrowser, CExtWA<CExtControlBar>)

    ON_WM_CREATE()

 END_MESSAGE_MAP()



void CFileBrowser::OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL /*bDisableIfNoHndler*/)

{

}



int CFileBrowser::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

    if( CExtWA<CExtControlBar>::OnCreate(lpCreateStruct) == -1 )

        return -1;



    m_wndShellCombo.Create(WS_VISIBLE|CBS_DROPDOWNLIST |

        CBS_OWNERDRAWFIXED | CBS_HASSTRINGS |

        CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP, CRect(10,10,100,100), this, IDC_SHELL_COMBO);

    m_wndShellCombo.FocusPath(_T("C:\\"));



    m_wndShellList.Create(LVS_REPORT | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, CRect(10, 110, 100, 200), this, IDC_SHELL_LIST);

    m_wndShellList.SetExtendedStyle( LVS_EX_UNDERLINEHOT|LVS_EX_UNDERLINECOLD );

    m_wndShellList.ModifyStyle( 0, LVS_EDITLABELS );



    return 0;

}


Regards,


Chris

Chris G. Aug 1, 2009 - 6:59 PM

Hello Prof-UIS,


thanks for the help. Now that i have created a shell combo and a shell list control i would like to configure them to suit my needs but i do not know how. This is what i would like to achieve:


Shell combo:

The tree inside the combo should show lines and enable expansion and colapsing of nodes


Shell list:

I would like to choose which columns to show (e.g. only the filenames)


 How can this be achieved?


Thank you & regards,

Chris

Technical Support Aug 2, 2009 - 1:17 PM

You can use the source code of the CExtShellDialogFile class as the sample. This dialog has 4 shell controls:

 CExtNCSB < CExtShellListCtrl > m_wndShellList;
      CExtNCSB < CExtShellTreeCtrl > m_wndShellTree;
      CExtNCSB < CExtShellComboBox > m_comboLookIn;
      CExtShellExtensionsComboBox m_comboFileTypes;

It initializes these controls in the CExtShellDialogFile::OnInitDialog() virtual method and handles notification from the shell controls for synchronizing them with each other:
 ON_REGISTERED_MESSAGE( CExtShellListCtrl::g_nMsgShellLocationChanged, OnShellListLocationChanged )
      ON_REGISTERED_MESSAGE( CExtShellComboBox::g_nMsgShellLocationChanged, OnShellComboLocationChanged )
      ON_REGISTERED_MESSAGE( CExtTreeCtrl::g_nMsgTreeItemDelayedFocus, OnShellTreeDelayedItemFocus )
      ON_REGISTERED_MESSAGE( CExtShellBase::g_nMsgShellItemExecute, OnShellItemExecute )

Now we will use code lines from the method to show you how to initialize shell tree and shell list controls. The shell tree control initialization is mostly performed by one line of code:
 m_wndShellTree.RefreshShellRoot();

Then you can focus some tree item:
 m_wndShellTree.FocusItem( m_wndShellTree.GetChildItem( TVI_ROOT ), true, false, true );

Then you can display content of the corresponding shell folder in the shell list control:
 HTREEITEM htiSelect = m_wndShellTree.GetFocusedItem();
      if( htiSelect != NULL )
      {
            CExtTreeCtrl::TREEITEMINFO_t & _TII = m_wndShellTree.TreeItemInfoGet( htiSelect );
            CExtShellItemData * pData = (CExtShellItemData*)_TII.m_lParam;
            ASSERT( pData != NULL );
            LPITEMIDLIST pidlSelect = (LPITEMIDLIST)pData->m_pidlAbsolute.GetPtr();
            ASSERT( pidlSelect != NULL );
            m_wndShellList.FocusPIDL( pidlSelect );
      }

The shell combo box above shell list and tree controls is also initialized with one line of code:
 m_comboLookIn.DelayFocusPIDL( pidlSelect );

Then you should take a look at the CExtShellDialogFile::OnShellTreeDelayedItemFocus(), CExtShellDialogFile::OnShellListLocationChanged(), CExtShellDialogFile::OnShellComboLocationChanged() and CExtShellDialogFile::OnShellItemExecute() handler methods which perform synchronization between shell controls. The first three handler methods are invoked when the focused shell item is changed in the shell combo/tree/list controls. The CExtShellDialogFile::OnShellItemExecute() method is invoked when user double clicks on some shell item in the shell control. If this control is shell list, then the file dialog should assume the IDOK button is clicked.



Chris G. Aug 3, 2009 - 4:28 AM

Hello Prof-UIS,


thank you for your help. Synchronizing data between those controls works now, but i still have the following two problems:


1. The shell list control is in report mode (LVS_REPORT) and displays the columns Name, Size, Type and so on. But i want to display only the Name column. I tried removing unneeded columns with DeleteColumn() but that causes an assertion. The same happens if i call GetHeaderCtrl().DeleteItem().


2. If i click into the shell combo box it shows me a tree without lines and without + and - symbols for expanding and collapsing the items. I would like to have a normal tree control in the shell combo box like the one used in CExtShellTreeCtrl so that the user can walk through the whole filesystem inside the shell combo box. That tree should of course show only folders. If he than selects a folder he should see its contents in the shell list control. So actually i just need to turn the tree inside the combo box to one that is expandable and collapsable with the + and - symbols. How can this be achieved?


Regards,


Chris


BTW: Answering support querries even on weekends shure deserves commendation! Great job!

Technical Support Aug 4, 2009 - 1:53 AM

The CExtShellListCtrl class has the following locally defined enumeration:

 enum e_shell_list_column_type_t
      {
            __ESLCT_NAME = -1,
            __ESLCT_SIZE = -2,
            __ESLCT_TYPE = -3,
            __ESLCT_DATE_MODIFIED = -4,
            __ESLCT_DATE_CREATED = -5,
            __ESLCT_DATE_ACCESSED = -6,
            __ESLCT_ATTRIBUTES = -7,
            __ESLCT_CUSTOM_TYPE = 0,
      };

And the following public array property:
 CArray < INT, INT > m_arrColumnTypes;

This array defines columns to display in the shell list view control and it contains the INT values which are really constants defined by the e_shell_list_column_type_t enumeration. This array is initialized in the constructor of the CExtShellListCtrl class:
 m_arrColumnTypes.Add( INT(__ESLCT_NAME) );
      m_arrColumnTypes.Add( INT(__ESLCT_SIZE) );
      m_arrColumnTypes.Add( INT(__ESLCT_TYPE) );
      m_arrColumnTypes.Add( INT(__ESLCT_DATE_MODIFIED) );
      m_arrColumnTypes.Add( INT(__ESLCT_DATE_CREATED) );
      m_arrColumnTypes.Add( INT(__ESLCT_DATE_ACCESSED) );
      m_arrColumnTypes.Add( INT(__ESLCT_ATTRIBUTES) );

This means you can create your own CExtShellListCtrl-derived class with the following code in its constructor:
 m_arrColumnTypes.RemoveAll();
      m_arrColumnTypes.Add( INT(__ESLCT_NAME) );

As result, only the Name column will appear.

The second question is very interesting. The shell combo box does not display any tree/shell tree. It really displays just one branch demonstrating the currently viewed shell folder and some neighborhood folders at each level. The shell combo box can be used for quick-jumping to neighborhood or parent folders only. So, we can assume your second question as feature request.



Chris G. Aug 4, 2009 - 7:11 AM

Hello Prof-UIS,


thank you for the detailed help. Now i got the shell list control exactly like i need it.


Are there any chances the shell combo box will be able to contain a full tree control like mentioned before? If yes, when could that feature be expected to be available? Would it then be possible to get it without waiting for the next official update of Prof-UIS?


Thanks & regards,


Chris

Technical Support Jul 31, 2009 - 7:46 AM

The CExtWA template class adds an anchoring feature to other windows. The CExtControlBar class implements a resizable control bar and it’s designed as a container for one child window which is automatically resized to cover the entire control bar’s client area. The CExtWA < CExtControlBar > template based class is incorrect usage of both the CExtWA and CExtControlBar classes. Please create one child dialog with browsing controls inside the control bar.