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

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


TreeView, ListView, Modeless Dialog.

elie e.e. bensaci -- ebensaci@nortel.ca
Monday, September 30, 1996

Hi there,

Environment:  Visual C++ 4.2, Win 95

I'm building an application using a splitter (1x2), and I have as well a modeless dialog 
boss which I can invoke from a toolbar menu. The modeless dialog box contain a property 
sheet control (3 property pages), every property page has a tree control. What I want to 
do is every time the user clicks on the tree control in the modeless dialog box, I want 
changes to appear in the ListView, How can I get this working?

------------------------------------------------
|			|			|	Modeless Dialog
|			|			|	
|			|			|	------------------------
|	TreeView	|	ListView	|	|			|
|			|			|	|			|
|			|			|	|	TreeControl		|
|			|			|	|			|
|			|			|	|			|
|			|			|	|			|
-------------------------------------------------	-------------------------

In the modeless dialog box:
===========================

Through a menu item (or toolbar), How can I make a specific property page to show when 
invoking the modeless dialog box?

Thanks a lot.



Gene Sewell -- genes@fast.net
Wednesday, October 02, 1996

[Mini-digest: 2 responses]

>Environment:  Visual C++ 4.2, Win 95
>
>I'm building an application using a splitter (1x2), and I have as well a
modeless dialog 
>boss which I can invoke from a toolbar menu. The modeless dialog box
contain a property 
>sheet control (3 property pages), every property page has a tree control.
What I want to 
>do is every time the user clicks on the tree control in the modeless dialog
box, I want 
>changes to appear in the ListView, How can I get this working?

I do this by sending user defined messages from view to view.  For example,
if a user clicks on a tree leaf, the tree view sends a message to the list
view like:
	if (m_ProfileDoc->mx_ListWnd) 
		m_ProfileDoc->mx_ListWnd->SendMessage(WM_NEW_TREE_LEAF, 0, 0);

I use the same doc for both views, the doc has a pointer to both windows,
and to any data that the list window needs to display.

Simple, but works well.

Cheers!
----
It is impossible to make anything foolproof because fools are so ingenious.

-unknown

-----From: Mario Contestabile

People seem to think there is something inherently built-into MFC which 
automagically
updates data in one control when an action in another control occurs. If you 
want to update
the data displayed by your list control when a node is selected in the tree 
control,
a) capture the TVN_SELCHANGED message for the tree control
b) update your list control 
You could even allow for dragging between the two controls. I'm assuming you
indeed have a tree and a list control, because your drawing mentions a treeview
and a listview.

mcontest@universal.com




Gabriel Parlea-Visalon -- Gabriel@derivs.demon.co.uk
Wednesday, October 02, 1996

In your message dated Monday 30, September 1996 you wrote :
> Hi there,
> 
> Environment:  Visual C++ 4.2, Win 95
> 
> I'm building an application using a splitter (1x2), and I have as well a 
modeless dialog 
> boss which I can invoke from a toolbar menu. The modeless dialog box contain a 
property 
> sheet control (3 property pages), every property page has a tree control. What 
I want to 
> do is every time the user clicks on the tree control in the modeless dialog 
box, I want 
> changes to appear in the ListView, How can I get this working?
> 
> ------------------------------------------------
> |			|			|	Modeless Dialog
> |			|			|	
> |			|			|	------------------------
> |	TreeView	|	ListView	|	|			
|
> |			|			|	|			
|
> |			|			|	|	TreeControl	
	|
> |			|			|	|			
|
> |			|			|	|			
|
> |			|			|	|			
|
> -------------------------------------------------	
-------------------------
> 
> In the modeless dialog box:
> ===========================
> 
> Through a menu item (or toolbar), How can I make a specific property page to 
show when 
> invoking the modeless dialog box?
> 
> Thanks a lot.
> 

Add ON_NOTIFY_REFLECT in your CTreeCtrl's message map or ON_NOTIFY in the 
property page's message map. For more information see Technical Note 60 which 
the Class Libray Reference entry for CTreeCtrl suggests also! There is an 
example of using reflected messages in TN062 and most probably in the samples.

CListView has one member function GetListCtrl() which returns a reference to the 
CListCtrl it is associated with. Use that to update the ListView. That is, if 
what you call ListView is derived from CListView.

The order of appearance of property pages in the property sheet is conditioned 
by the order of AddPage()'s. So, for example, keep the pointers to your property 
pages in an array and set the AddPage() start index through the menu.

I hope this helps you,

Gabriel

-- 
                             Gabriel Parlea-Visalon
                               Software Engineer
                           Derivative Trading Systems
                           gabriel@derivs.demon.co.uk





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