Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-2000
  5. //
  6. // File: Header.cxx
  7. //
  8. // Contents: Used to maintain / display listview header
  9. //
  10. // History: 27-Nov-1996 KyleP Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #pragma hdrstop
  15. #include <header.hxx>
  16. CHeaderItem::CHeaderItem( unsigned id,
  17. WCHAR const * pwcsName,
  18. int Format,
  19. int Width,
  20. BOOL fInUse )
  21. : _id( id ),
  22. _Format( Format ),
  23. _Width( Width ),
  24. _fInUse( fInUse )
  25. {
  26. Win4Assert( wcslen(pwcsName) < ccMaxName );
  27. wcscpy( _wcsName, pwcsName );
  28. }
  29. CListViewHeader::CListViewHeader()
  30. {
  31. }
  32. void CListViewHeader::Add( unsigned id,
  33. WCHAR const * pwcsName,
  34. int Format,
  35. int Width )
  36. {
  37. CHeaderItem * pItem = new CHeaderItem( id, pwcsName, Format, Width );
  38. _aColumn.Add( pItem, _aColumn.Count() );
  39. }
  40. void CListViewHeader::Display( IHeaderCtrl * pHeader )
  41. {
  42. for ( unsigned i = 0; i < _aColumn.Count(); i++ )
  43. {
  44. CHeaderItem * pItem = _aColumn.Get( i );
  45. if ( pItem->IsInUse() )
  46. pHeader->InsertColumn( i, pItem->Name(), pItem->Format(), pItem->Width() );
  47. }
  48. }
  49. void CListViewHeader::Update( IHeaderCtrl * pHeader )
  50. {
  51. for ( unsigned i = 0; i < _aColumn.Count(); i++ )
  52. {
  53. CHeaderItem * pItem = _aColumn.Get( i );
  54. if ( pItem->IsInUse() )
  55. {
  56. int Width;
  57. SCODE sc = pHeader->GetColumnWidth( i, &Width );
  58. if ( SUCCEEDED( sc ) )
  59. pItem->SetWidth( Width );
  60. }
  61. }
  62. }