I have a ListView created by CreateWindowExW()
with WC_LISTVIEWW
. I then create columns using LVCOLUMNW
and set the texts via pszText
.
I would like the column texts of this list view to be aligned to the right, so I added WS_EX_LAYOUTRTL
to the extended style when doing CreateWindowExW()
. Then when I create and add the columns to this ListView, text/name/title of each column are aligned to the right, as expected, so far so good.
The issue is, if I exclude WS_EX_LAYOUTRTL
from CreateWindowExW()
, and instead, use SetWindowLongPtrW
to add this RTL extended style to the ListView, and then, create and add LVCOLUMNW
s, it would has no effect, the text/name/title of each column are still left-aligned, even the order of columns are not RTL, the first added column would be at far left, whereas with WS_EX_LAYOUTRTL
taking effect, it should start from far right.
SetWindowLongPtrW
returns a non-zero value which matches the initial extended style combination, so the function call should be a success. The only thing I am thinking now is maybe with ListView and LVCOLUMNW
, WS_EX_LAYOUTRTL
simply cannot be added after ListView had already been created?
You want to use the LVCFMT_RIGHT
format flag on the LVCOLUMN
structure.