May 06, 2024, 04:39:22 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Right Justify columns in Listview

Started by billhsln, March 12, 2012, 09:54:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I found this in a Visual Basic source code Forum and have modified it to used in IWB.

$include "commctrl.inc"
has the definitions needed for below.

'ListView Column Flag Messages
Public Const LVCF_FMT = &H1
Public Const LVCF_WIDTH = &H2
Public Const LVCF_TEXT = &H4
Public Const LVCF_SUBITEM = &H8
Public Const LVCF_IMAGE = &H10
Public Const LVCF_ORDER = &H20


'ListView Messages
Public Const LVM_FIRST = &H1000
Public Const LVM_SETCOLUMNA = (LVM_FIRST + 26)
Public Const LVM_SETCOLUMN = LVM_SETCOLUMNA


'ListView Column Format Messages
Public Const LVCFMT_LEFT = &H0
Public Const LVCFMT_RIGHT = &H1
Public Const LVCFMT_CENTER = &H2
Public Const LVCFMT_JUSTIFYMASK = &H3
Public Const LVCFMT_IMAGE = &H800 'IE 3+ only
Public Const LVCFMT_BITMAP_ON_RIGHT = &H1000
Public Const LVCFMT_COL_HAS_IMAGES = &H8000&

put the code below in your program.

$include "commctrl.inc"
Dim lvFormat As LVCOLUMN

lvFormat.mask = LVCF_FMT
lvFormat.fmt = LVCFMT_RIGHT

...then right after your column headers you will want
to send a windows message (substitute your
ListView in place of D1_LV)...my Dialog is D1,
0,6,7,8 is the listview column (zero based)

SendMessage(D1, LVM_SETCOLUMN, 0, lvFormat,D1_LV)
SendMessage(D1, LVM_SETCOLUMN, 6, lvFormat,D1_LV)
SendMessage(D1, LVM_SETCOLUMN, 7, lvFormat,D1_LV)
SendMessage(D1, LVM_SETCOLUMN, 8, lvFormat,D1_LV)

I have tried this in one of my programs and it does right justify correctly.

I hope some one else will find this of use,
Bill
When all else fails, get a bigger hammer.