15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Explorer like list labels?

Martin Wawrusch -- wawrusch@accs.co.at
Wednesday, January 10, 1996

I am developing an explorer like win95 app that is used for
the maintenance part of our application suite. I use a tree
view on the left and a list view on the right. I would like
to add a label above the list view to indicate which part
of the tree was selected (like "Contents of 'ACCOUNTS'").

This label should be part of the right splitter window. The
question is: How can I do that within the MFC 4.0 Framework?

Any help is very much appreciated.

Martin





-- 
Martin Wawrusch			| ESBMASAP, BNS  A. Einstein
ACCS Software			| Tel. : +43 1 983 46 91 
Huetteldorferstr. 163/23	| Fax. : +43 1 983 01 00
A-1140 Vienna, Austria		| EMail: wawrusch@accs.co.at



Ken Freeman -- kfreeman@viewlogic.com
Thursday, January 11, 1996

[Mini-digest: 2 responses]

Martin Wawrusch wrote:
> 
> I am developing an explorer like win95 app that is used for
> the maintenance part of our application suite. I use a tree
> view on the left and a list view on the right. I would like
> to add a label above the list view to indicate which part
> of the tree was selected (like "Contents of 'ACCOUNTS'").
> 
> This label should be part of the right splitter window. The
> question is: How can I do that within the MFC 4.0 Framework?
> 

I've done that using CStatusWnd's and resizing the panes when the
corresponding list view was resized.  It worked, but I had to add
some "fudge code" so the sizes would match on Win95, NT, and Win32s.

I think a better approach would be to use a CHeaderCtrl.

A third alternative is to embed a static control at the top of each view,
so the CSplitterWnd extends through the captions.  I tried this, but
visually it did not look quite right.

Ken

-----From: Mario Contestabile 

I developped exactly that. The "label" you make reference to can be a column. 
Instead of using InsertItem() use InsertColumn().

In your list view class (derived from CListView)

CListCtrl& ListCtrl = (CListCtrl&) GetListCtrl();

LV_COLUMN lvc;
lvc.mask     = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; // 
fmt,pszText,subitem & cx members are valid
lvc.fmt      = LVCFMT_LEFT;                                      // column 
alignment
lvc.cx       = ListCtrl.GetStringWidth(_T("WWWWWWWWWWW")) + 16;  // in pixels, 
11 'W's, 16 pixels for the small icon
lvc.pszText  = _T("File");       
lvc.iSubItem = 0;
ListCtrl.InsertColumn(0, &lvc);

You probably already have the proper view initialization in your CMDIChildWnd 
derived class.

::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext){

if(!m_wndSplitter.CreateView(0,1,      // CSplitterWnd member of your 
CMDIChildWnd class
 
RUNTIME_CLASS(your_listview_class_derived_from_CListView),CSize(0,0),pContext)) 
return FALSE;
}

Depending on the selection in the tree control you add and remove columns as 
you seem fit and/or change their text. This is what explorer
does.

mcontest@universal.com





| Вернуться в корень Архива |