How to determine justification in a ListView control in Visual C++ (198589)



The information in this article applies to:

  • Microsoft Visual C++ 4.0
  • Microsoft Visual C++ 4.1
  • Microsoft Visual C++, 32-bit Enterprise Edition 4.2
  • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 4.2
  • Microsoft Visual C++, 32-bit Professional Edition 5.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q198589
Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.

SUMMARY

The documentation for the LVCOLUMN structure used by the ListView common control indicates that you can use the fmt member of the LVCOLUMN structure to set the justification of a column in the ListView control. This article shows you how to determine the value of the justification of a column in the ListView control.

MORE INFORMATION

Before you check the value of the fmt member of the LVCOLUMN structure, the value of this member must be bitwise "anded" with the flag LVCFMT_JUSTIFYMASK, which is defined in Commctrl.h. For example, the following code shows you how to determine whether the second column in a list view is right, center, or left justified:
   LVCOLUMN lvc;
   // Assume hWndOfLV is an HWND of an existing ListView control window.
   if(ListView_GetColumn(hWndOfLV, GetColumn, 1, &lvc))
   {
      switch(lvc.fmt & LVCFMT_JUSTIFYMASK)
      {
         case LVCFMT_RIGHT:
            // Right justified
            break;
         case LVCFMT_CENTER:
            // Center justified
            break;
         case LVCFMT_LEFT:
            // Left justified
            break;
      }
   }

Modification Type:MajorLast Reviewed:1/11/2006
Keywords:kbCtrl kbhowto KB198589 kbAudDeveloper