Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. set align for header control

set align for header control

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _skidrow_vn_
    wrote on last edited by
    #1

    I want to set align for each column in my listview so I get handle of header control of listview then use SetItem member function of CHeaderCtrl to do this. About Align => ok, I got it but I lost all caption (text) in each column header (no text in headers) if I use only hdi.mask = HDI_TEXT; >> my texts will not disappear What I need to do to set align for each column and all text is still appear ///////////////////////////////////////////////// #define LEFT 1 #define CENTER 2 #define RIGHT 3 MyListViewCtrl m_ListCtrl; m_ListCtrl.cColumnMax = 4; m_ListCtrl.InsertColumn (0, "#");//left-default m_ListCtrl.InsertColumn (1, "ID");//left m_ListCtrl.rgcAlign[1]=1; m_ListCtrl.InsertColumn (2, "Name");//center m_ListCtrl.rgcAlign[2]=2; m_ListCtrl.InsertColumn (3, "Cost");//right m_ListCtrl.rgcAlign[3]=3; m_ListCtrl.SetAlign();//set align for all column //////////////////////////////////////////// void MyListViewCtrl::SetAlign() { CHeaderCtrl* pHeader = GetHeaderCtrl( ); HDITEM hdi; for (int i=0; iGetItem(i, &hdi)); hdi.fmt = (rgcAlign[i]==LEFT?HDF_LEFT:(rgcAlign[i]==CENTER?HDF_CENTER:HDF_RIGHT)); hdi.pszText = buffer; hdi.cchTextMax = 256; VERIFY(pHeader->SetItem(i, &hdi)); } }

    D 1 Reply Last reply
    0
    • _ _skidrow_vn_

      I want to set align for each column in my listview so I get handle of header control of listview then use SetItem member function of CHeaderCtrl to do this. About Align => ok, I got it but I lost all caption (text) in each column header (no text in headers) if I use only hdi.mask = HDI_TEXT; >> my texts will not disappear What I need to do to set align for each column and all text is still appear ///////////////////////////////////////////////// #define LEFT 1 #define CENTER 2 #define RIGHT 3 MyListViewCtrl m_ListCtrl; m_ListCtrl.cColumnMax = 4; m_ListCtrl.InsertColumn (0, "#");//left-default m_ListCtrl.InsertColumn (1, "ID");//left m_ListCtrl.rgcAlign[1]=1; m_ListCtrl.InsertColumn (2, "Name");//center m_ListCtrl.rgcAlign[2]=2; m_ListCtrl.InsertColumn (3, "Cost");//right m_ListCtrl.rgcAlign[3]=3; m_ListCtrl.SetAlign();//set align for all column //////////////////////////////////////////// void MyListViewCtrl::SetAlign() { CHeaderCtrl* pHeader = GetHeaderCtrl( ); HDITEM hdi; for (int i=0; iGetItem(i, &hdi)); hdi.fmt = (rgcAlign[i]==LEFT?HDF_LEFT:(rgcAlign[i]==CENTER?HDF_CENTER:HDF_RIGHT)); hdi.pszText = buffer; hdi.cchTextMax = 256; VERIFY(pHeader->SetItem(i, &hdi)); } }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Check the replies in the microsoft.public.vc.mfc newsgroup.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups