Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
I have CListCtrl type report.
I need to write into it's items multiline text.
 
How can i achieve this?
Posted 22-Feb-10 20:34pm
AJ831.2K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have to implement an own derivation of CListCtrl
 
to overwrite its reactions for WM_MEASUREITEM and WM_DRAWITEM Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

class CYourCtrl : public CListCtrl
{
public:
  CYourCtrl();
  virtual ~CYourCtrl();
protected: 
  //{{AFX_MSG(CYourCtrl) 
  virtual void DrawItem       (LPDRAWITEMSTRUCT);
  afx_msg void MeasureItem    (LPMEASUREITEMSTRUCT);    
  //}}AFX_MSG
  DECLARE_MESSAGE_MAP()
};
 
...
BEGIN_MESSAGE_MAP(CYourCtrl, CListCtrl)
    ON_WM_MEASUREITEM_REFLECT()    
END_MESSAGE_MAP()
 
//
void CYourCtrl::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
  if (lpMeasureItemStruct) {
    lpMeasureItemStruct->itemHeight = ...; // set your hight here
  }
}
 
Please remember to set the LVS_OWNERDRAWFIXED
at creating of your control or in your .rc file Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

By default CListCtrl does not draw its textes in the multiline mode.
That is why you need the following function too Smile | :) :
void CYourCtrl::DrawItem(LPDRAWITEMSTRUCT pDIS)
{
  if (pDIS) {
    // the first step
    if (ODA_DRAWENTIRE == pDIS->itemAction) {
      // Draw your content here
    }
    // there are other cases too :)
  }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Do you have a variable of the control
in the CYourView : public CFormView ?
 
Please place it there (if not) of the type CYourCtrl
and create it:
 
void CYourView::OnInitialUpdate()
{
  m_cYourCtrl.Create(..);
  // Set styles here
...
}
 
void CYourView::OnDestroy()
{
  m_cYourCtrl.DestroyWindow();
...
}
Now you could use some words about the working Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 10

It would be OK by replacing of CListCtrl with CYourCtrl, yes Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 339
1 DineshMaind 95
2 Sergey Alexandrovich Kryukov 94
3 majid torfi 85
4 kbrandwijk 75
0 Zubair MCA 55
1 OriginalGriff 55
2 sankarsan parida 55
3 harshavardhan12345678 45
4 Sandeep Londhe 45


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 23 Feb 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100