PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Jean-Pierre LEROY on May 30, 2005, 02:23:52 PM

Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: Jean-Pierre LEROY on May 30, 2005, 02:23:52 PM
Hi,

Just a very small problem; when I create a ListView, even if I specified the %LVCFMT_RIGHT flag, the text is still left-aligned for the first column (column 0); the two others columns (columns 1 and 2) are well right aligned.

The problem is only for the first column, column 0.

Here is some simple code :


'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                        hWndForm As Dword, _  ' handle of Form
                        ByVal UserData As Long _  'optional user defined Long value
                        ) As Long

                       
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 0, "Column1", %LVCFMT_RIGHT, 100
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 1, "Column2", %LVCFMT_RIGHT, 100
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 2, "Column3", %LVCFMT_RIGHT, 100

Local lrow As Long
Local lcol As Long
     
For lrow = 0 To 10
  For lcol = 0 To 2
      FF_ListView_InsertItem HWND_FORM1_LISTVIEW1, lrow, lcol, Str$(lrow) & Str$(lcol), 0, 0
  Next
Next

End Function


Paul, can you find a fix for this problem ?

Thank you.
Jean-Pierre.
Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: Jose Roca on May 30, 2005, 04:29:41 PM
The first column of a ListView is always left aligned. It is by design (by Microsoft design, not FireFly). Possible workarounds are to make it invisible and don't use it or use it for a left aligned column and change the placement order.
Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: TechSupport on May 30, 2005, 04:57:16 PM
Thanks Jose - I was not aware of that limitation.
Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: Roger Garstang on May 30, 2005, 10:37:14 PM
Yup, it sucks.  Sometimes it would be nice to right align them.  There is also supposed to be some limitation of not being able to delete the first column too, but I never had any problems with it...M$ could change the behavior at any time I guess though since it is documented to not be allowed.
Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: Jean-Pierre LEROY on May 31, 2005, 01:21:51 AM
Thank you Jose, Paul and Roger for your help.

Microsoft put some informations about this limitation in their WebSite :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/structures/lvcolumn.asp

Nevertheless, I found a very easy solution to solve this problem; if I use the FF_ListView_SetColumnAlignment to force the text to be right-aligned for the first column (column 0) everything works fine !

Here is the modified code :


Function FORM1_WM_CREATE ( _
                        hWndForm As Dword, _  ' handle of Form
                        ByVal UserData As Long _  'optional user defined Long value
                        ) As Long

                       
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 0, "Column1", %LVCFMT_RIGHT, 100
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 1, "Column2", %LVCFMT_RIGHT, 100
FF_ListView_InsertColumn HWND_FORM1_LISTVIEW1, 2, "Column3", %LVCFMT_RIGHT, 100
FF_ListView_SetColumnAlignment (HWND_FORM1_LISTVIEW1, 0, %LVCFMT_RIGHT)

Local lrow As Long
Local lcol As Long
     
For lrow = 0 To 10
  For lcol = 0 To 2
      FF_ListView_InsertItem HWND_FORM1_LISTVIEW1, lrow, lcol, Str$(lrow) & Str$(lcol), 0, 0
  Next
Next

End Function


It's very stange why Windows doesn't accept the %LVCFMT_RIGHT flag with the LVM_INSERTCOLUMN Message but accept the %LVCFMT_RIGHT flag with the LVM_SETCOLUMN Message ?

Windows Programming is sometimes a bit weird !

Thank's,
Jean-Pierre
Title: FF_ListView_InsertColumn with %LVCFMT_RIGHT flag
Post by: Jose Roca on May 31, 2005, 01:36:48 AM
It all depends of how mad is the programmer that makes the control.