c++visual-studio-2012mfcclistbox

is there any method available for change the property "right align text" of CListBox in MFC(c++)?


I am working on Microsoft Foundation Class (c++)chat application in which i want to show client message on right side of the list box,There is a property available "Right align text" but i want to do it by method. because default Left side text is also necessary for me.

Thank You.


Solution

  • Use ModifyStyleEx to add/remove the extended style WS_EX_RIGHT as required, e.g. to right-align:

    GetDlgItem(IDC_LIST1)->ModifyStyleEx(NULL, WS_EX_RIGHT);