Sourcecode documentation of module DispCtrl.dll
Overviews
Modules
C/C++ Elements
Classes and Class Members
Functions
Structures and Enums
Constants
Help file built: 02/03/00
Gerolf Kühnel A&D SH12
Copyright \'a9 Siemens AG 1999. All Rights Reserved.
TreeListView.cpp - Implementation of <c CTreeListView>
Filename: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Description
Copyright (C) 1999
Gerolf Kühnel
Elements defined in this Module
TreeListView.h - Declaration of <c CTreeListView>
Filename: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Description
Copyright (C) 1999
Gerolf Kühnel
Elements defined in this Module
CMyTreeCtrl class
CMyTreeCtrl class CMyTreeCtrl: public CTreeCtrl
The used treecontrol. The standard MFC class is overwritten to get a notification if
an item is inserted to the treecontrol
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Messagehandler for the TreeCtrl to be used
Class Members
- afx_msg LRESULT OnInsertItem(WPARAM wParam, LPARAM lParam)
- overwritten, to enable notifying the parent above new items
- afx_msg LRESULT OnLButtonDblClk(WPARAM wParam, LPARAM lParam)
- overwritten, to enable doubleclick beside the objects
- afx_msg LRESULT OnLButtonClk(WPARAM wParam, LPARAM lParam)
- overwritten, to enable selektion with click beside the objects
CMyTreeCtrl::OnInsertItem
LRESULT CMyTreeCtrl::OnInsertItem(WPARAM wParam, LPARAM lParam)
overwienable the parent to do something when an item is inserted into the tree
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
handle of the new TreeItem or NULL
Parameters
- wParam
- 0
- lParam
- Address of a TVINSERTSTRUCT structure that specifies the attributes of the tree view item
Back to CMyTreeCtrl
CMyTreeCtrl::OnLButtonClk
LRESULT CMyTreeCtrl::OnLButtonClk(WPARAM wParam, LPARAM lParam)
checks, if there was a click right of the normal treeitem and puts the x-Pos to left
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
the returnvalue of the default procedure
Parameters
- wParam
- Indicates whether various virtual keys are down, see Win32 documentation
- lParam
- specifies the Mousecursosposition, see Win32 documentation
Back to CMyTreeCtrl
CMyTreeCtrl::OnLButtonDblClk
LRESULT CMyTreeCtrl::OnLButtonDblClk(WPARAM wParam, LPARAM lParam)
checks, if there was a doubleclick right of the normal treeitem and puts the x-Pos to left
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
the returnvalue of the default procedure
Parameters
- wParam
- Indicates whether various virtual keys are down, see Win32 documentation
- lParam
- specifies the Mousecursosposition, see Win32 documentation
Back to CMyTreeCtrl
CMyTreeObj class
CMyTreeObj class CMyTreeObj: public CObject
A class that holds the texts of the columns for each item.
I use this class, so I can use a CMap to get the columntexts to a HTREEITEM, because
CMap wants to have Objects in it that have got an operator=.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Class Members
- CStringArray m_strColumns
- dynamic array that holds the columntextes for one object
- CMyTreeObj& operator=(CMyTreeObj& obj)
- operator= to copy the StringArray from one object to an other
CMyTreeObj::operator=
CMyTreeObj& CMyTreeObj::operator=(CMyTreeObj& obj)
copys the stringarray from one object to the next
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
referenz to the object
Parameters
- obj
- referenz to the object containig the data to be copied
Back to CMyTreeObj
CTreeListView class
CTreeListView class CTreeListView: public CView
A class that behaves like a CTreeView. But the difference is, that it enables you to use
coplumns like in a ListView.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
protected attributes
Class Members
- CMap<HTREEITEM, HTREEITEM, CMyTreeObj, CMyTreeObj&> m_Entries
- List of columntextes, which can be reached with the corresponding treeitem handle
- CMyTreeCtrl m_ctrlTree
- contained treecontrol
- CHeaderCtrl m_ctrlHeader
- contained headercontrol
- HeaderData* m_vsCol
- structure with data of the columns. used that we needn't get that values all times at drawing
- COLORREF m_colBackColor
- backgroundcolor, not really used but inserted for drawing (set to default)
- COLORREF m_colHilightText
- color of the text of a selected element
- COLORREF m_colText
- textcolor, not really used but inserted for drawing (set to default)
- CBrush m_BackBrush
- brush to fill the background of a selected element
- bool m_bDescriptionDisplay
- should the header be displayed?
- long m_nOffset
- Scrollingposition of the view
- long m_nHeaderWidth
- width of the header, safed for scrolling
- long m_nNrColumns
- -number of columns used
constructors and destructors
- CTreeListView()
- protected constructor used by dynamic creation
- virtual ~CTreeListView()
- destructor to delet the structurs and arrays
protected functions (helperfunctions for internal use)
- void CalculateClientRects(CRect& rcBase, CRect& rcTree, CRect& rcHeader)
- calculates the rectangles for the childcontrols
- void SizeObjects(void)
- resizes all childobjects of the view
- bool ResetScrollbar(void)
- checks, if the horizontal scrollbar is necessary and,hides / shows it
- void DrawTreeItem(bool bFocus, CRect rcItem, HDC hdc, HTREEITEM hItem)
- draws the text of the treeitems (all columns!!)
- void UpdateColStruct(void)
- updates the m_vsCol variable to the actual value
- BOOL OnCustomdrawTree(LPNMHDR pNmhdr, LRESULT* pResult)
- set's up the drawingcontext and triggers the itemds textdrawing
- BOOL OnEndTrack(LPNMHDR pNmhdr, LRESULT* pResult)
- triggers the update of the m_vsCol - variable (user resized the Columns)
- BOOL OnDeleteItem(LPNMHDR pNmhdr, LRESULT* pResult)
- deletes all columndata for this object
protected MFC messagemap and message handlers
{{AFX_MSG(CTreeListView)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
- creates the childcontrols
- afx_msg void OnSize(UINT nType, int cx, int cy)
- resizes the childcontrols
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- scrolls the tree and the header
- afx_msg LRESULT OnInsertItem(WPARAM wParam, LPARAM lParam)
- indicates, that an item is inserted in the tree
Overrides
ClassWizard generated virtual function overrides
{{AFX_VIRTUAL(CTreeListView)
- virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
- handles all notifications like customdraw, delete, ...
- virtual void OnDraw(CDC* pDC)
- not used, but nessaccary, becaus this function is pure virtual in CView
public Operations, used from the client
- int InsertColumn( int nCol, const LVCOLUMN* pColumn )
- Inserts a new column in the TreeListView
- int InsertColumn( int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1 )
- Inserts a new column in the TreeListView
- BOOL DeleteColumn( int nCol )
- Call this function to delete a column from the TreeListView control
- BOOL SetSubItemText( HTREEITEM hItem, int nSubItem, CString strBuffer)
- Changes the text of a list view subitem
- BOOL GetSubItemText( HTREEITEM hItem, int nSubItem, CString& strBuffer)
- Retrieves the text of a list view subitem
- CImageList* GetHeaderImageList()
- Retrieves the handle of the Header control used
- CImageList* SetHeaderImageList( CImageList * pImageList)
- Assigns an image list to the Header control
- CTreeCtrl& GetTreeCtrl()
- Returns a reference to the tree control associated with the view
- void ShowHeader(bool bShow)
- Shows or hides the Header control
CTreeListView::CalculateClientRects
void CTreeListView::CalculateClientRects(CRect& rcBase, CRect& rcTree, CRect& rcHeader)
Calculates the Rects for the Windows
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- rcBase
- Referenc to the Bounding Rectangle
- rcTree
- Referenc to the Tree Rectangle
- rcHeader
- Referenc to the Header Rectangle
Back to CTreeListView
CTreeListView::CTreeListView
CTreeListView::CTreeListView(void)
initialises all variables
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Back to CTreeListView
CTreeListView::DeleteColumn
BOOL CTreeListView::DeleteColumn(int nCol)
Call this function to delete a column from the tree list view control.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
Nonzero if successful; otherwise zero.
Parameters
- nCol
- Index of the column to be deleted.
Back to CTreeListView
CTreeListView::DrawTreeItem
void CTreeListView::DrawTreeItem(bool bFocus, CRect rcItem, HDC hdc, HTREEITEM hItem)
draws the text of the treeitems (all columns!!)
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- bFocus
- is the focus on the specified item?
- rcItem
- Rectangle of the item
- hdc
- Handle of the DeviceContext to draw to
- hItem
- Handle of the tree item that is to be drawn
Back to CTreeListView
CTreeListView::GetHeaderImageList
CImageList* CTreeListView::GetHeaderImageList(void)
retrieves the imagelist of the headercontrol (if there is one)
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
a pointer to the headers imagelist or NULL
Back to CTreeListView
CTreeListView::GetSubItemText
BOOL CTreeListView::GetSubItemText(HTREEITEM hItem, int nSubItem, CString& strBuffer)
retrieves the text of a specified column of a tree list item
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
Nonzero if successful; otherwise zero.
Parameters
- hItem
- Handle of the item whose text is to be set.
- nSubItem
- Index of the subitem, or zero to set the item label.
- strBuffer
- Referenz to a string that should get the item text
Developer Notes
be sure only to use valid handles, that you got from this view or from the treectrl!!
Back to CTreeListView
CTreeListView::GetTreeCtrl
CTreeCtrl& CTreeListView::GetTreeCtrl(void)
Returns a reference to the tree control associated with the view.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
referenc to the tree ctrl
Back to CTreeListView
CTreeListView::InsertColumn
int CTreeListView::InsertColumn(int nCol, const LVCOLUMN* pColumn)
Inserts a new column in a treelist view control.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
The index of the new column if successful or -1 otherwise.
Parameters
- nCol
- The index of the new column.
- pColumn
- Address of an LVCOLUMN structure that contains the attributes of the new column.
Back to CTreeListView
CTreeListView::InsertColumn
int CTreeListView::InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
Inserts a new column in a treelist view control.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
The index of the new column if successful or -1 otherwise.
Parameters
- nCol
- The index of the new column.
- lpszColumnHeading
- Address of a string containing the columns heading.
- nFormat
- Integer specifying the alignment of the column. It can be one of these values:
LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER.
- nWidth
- Width of the column, in pixels. If this parameter is -1, the column width is not set.
- nSubItem
- Index of the subitem associated with the column. If this parameter is -1, no subitem
is associatied with the column.
Back to CTreeListView
CTreeListView::OnCreate
int CTreeListView::OnCreate(LPCREATESTRUCT lpCreateStruct)
Creates the TreeCtrl and the Header that is used
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
OnCreate must return 0 to continue the creation of the CWnd object. If the application returns -1, the window will be destroyed.
Parameters
- lpCreateStruct
- Points to a CREATESTRUCT structure that contains information about the CWnd object being created.
Back to CTreeListView
CTreeListView::OnCustomdrawTree
BOOL CTreeListView::OnCustomdrawTree(LPNMHDR pNmhdr, LRESULT* pResult)
set's up the drawingcontext and triggers the itemds textdrawing
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
An application returns nonzero if it processes this message; otherwise 0.
Parameters
- pNmhdr
- Pointer to a notification message (NMHDR) structure that contains the notification code and additional information.
For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first
member.
- pResult
- Pointer to an LRESULT variable in which to store the result code if the message is handled.
Back to CTreeListView
CTreeListView::OnDeleteItem
BOOL CTreeListView::OnDeleteItem(LPNMHDR pNmhdr, LRESULT* pResult)
when an item is to be deleted, we delete its columndata (the texts)
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
always TRUE
Parameters
- pNmhdr
- Pointer to a notification message (NMHDR) structure that contains the notification code and additional information.
For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first
member.
- pResult
- Pointer to an LRESULT variable in which to store the result code if the message is handled.
Back to CTreeListView
CTreeListView::OnDraw
void CTreeListView::OnDraw(CDC* pDC)
normally this function draws the window, not here. we let the system do thw job for us.
but it is forbidden to remove the function, because it's pure virtual in the base class
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- pDC
- pointer to the device context to draw to (see Win32 documentation)
Back to CTreeListView
CTreeListView::OnEndTrack
BOOL CTreeListView::OnEndTrack(LPNMHDR pNmhdr, LRESULT* pResult)
indicates, that an Headercolumn has changed his size
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
always FALSE
Parameters
- pNmhdr
- Pointer to a notification message (NMHDR) structure that contains the notification code and additional information.
For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first
member.
- pResult
- Pointer to an LRESULT variable in which to store the result code if the message is handled.
Back to CTreeListView
CTreeListView::OnHScroll
void CTreeListView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- nSBCode
- Specifies a scroll-bar code that indicates the users scrolling request. See win32 docu
- nPos
- Specifies the scroll-box position if the scroll-bar code is SB_THUMBPOSITION or SB_THUMBTRACK;
otherwise, not used. Depending on the initial scroll range, nPos may be negative and should be
cast to an int if necessary.
- pScrollBar
- If the scroll message came from a scroll-bar control, contains a pointer to the control. If the
user clicked a windows scroll bar, this parameter is NULL. The pointer may be temporary and should
not be stored for later use.
Back to CTreeListView
CTreeListView::OnInsertItem
LRESULT CTreeListView::OnInsertItem(WPARAM wParam, LPARAM lParam)
used to notify the view trhat a new item is inserted, so the view can insert a new string into the lists
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
always 0
Parameters
- wParam
- handle of the new treeitem (HTREEITEM)
- lParam
- not used
Back to CTreeListView
CTreeListView::OnNotify
BOOL CTreeListView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control
requires some kind of information.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
An application returns nonzero if it processes this message; otherwise 0.
Parameters
- wParam
- Identifies the control that sends the message if the message is from a control. Otherwise, wParam is 0.
- lParam
- Pointer to a notification message (NMHDR) structure that contains the notification code and additional information.
For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first
member.
- pResult
- Pointer to an LRESULT variable in which to store the result code if the message is handled.
Back to CTreeListView
CTreeListView::OnSize
void CTreeListView::OnSize(UINT nType, int cx, int cy)
The framework calls this member function after the windows size has changed.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- nType
- Specifies the type of resizing requested. See Win 32 docu
- cx
- Specifies the new width of the client area.
- cy
- Specifies the new hight of the client area.
Back to CTreeListView
CTreeListView::ResetScrollbar
bool CTreeListView::ResetScrollbar(void)
Resets the horizontal scrollbar and resizes the Windows, if neccessary
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
If successfull, the return value is TRUE else it is FALSE
Back to CTreeListView
CTreeListView::SetHeaderImageList
CImageList* CTreeListView::SetHeaderImageList(CImageList* pImageList)
sets the imagelist of the headercontrol
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
a pointer to the headers imagelist or NULL
Parameters
- pImageList
- pointer to the imagelist to set
Back to CTreeListView
CTreeListView::SetSubItemText
BOOL CTreeListView::SetSubItemText(HTREEITEM hItem, int nSubItem, CString strBuffer)
Changes the text of a tree list view item or subitem.
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
Nonzero if successful; otherwise zero.
Parameters
- hItem
- Handle of the item whose text is to be set.
- nSubItem
- Index of the subitem, or zero to set the item label.
- strBuffer
- String that contains the new item text.
Developer Notes
be sure only to use valid handles, that you got from this view or from the treectrl!!
Back to CTreeListView
CTreeListView::ShowHeader
void CTreeListView::ShowHeader(bool bShow)
turns the columnheaders on / off
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Parameters
- bShow
- should the columnheaders be shown?
Back to CTreeListView
CTreeListView::SizeObjects
void CTreeListView::SizeObjects(void)
resizes the Controls
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Back to CTreeListView
CTreeListView::UpdateColStruct
void CTreeListView::UpdateColStruct(void)
updates the m_vsCol variable to the actual value
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Back to CTreeListView
CTreeListView::~CTreeListView
CTreeListView::~CTreeListView(void)
frees all memory
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Back to CTreeListView
StretchWidth
static long StretchWidth(long nWidth, long nMeasure)
streches a long to an fitting multiply of nMeasure
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.CPP
Return Value
new width
Parameters
- nWidth
- old witdh
- nMeasure
- Measur
UNUSED_PARAM
void UNUSED_PARAM( a)
Makro used to avoid warning for not used parameters of a function
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Parameters
- a
- unused parameter
TVMYN_INSERTITEM
const UINT TVMYN_INSERTITEM;
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Message, that an Item was inserted
TVS_NOHSCROLL
const UINT TVS_NOHSCROLL;
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
TreeViewStyle, that switches off the Horizontal Scroll bar.
New Style, that is not defined in Headers, that I could get (ComCtl32.dll version 5.8!)
_HeaderData structure
struct {
long nWidth;
RECT rcDefault;
UINT nAlingment;
} _HeaderData;
Structure for nessassary data wich is to be got from the header for drawing
Defined in: D:/DOKUMENTATION/PROJEKTE/CODEPROJECT/TREELISTVIEW/TREELISTCTRL/TREELISTVIEW.H
Members
- nWidth
- width of the column
- rcDefault
- Rectangle of the ColumnHeaderItem (used for left and right value of the item's column)
- nAlingment
- alignment of the column