Restored from previous forum. Originally posted by gnozal.
I am trying to change columns styles in a ListIconView gadget.
For example :
; Change column style to right-aligned.
ColumnStyle.LV_COLUMN
ColumnStyle\imask = #LVCF_FMT
ColumnStyle\fmt = #LVCFMT_RIGHT
; Send message
SendMessage_(GadgetID(#ListIconView), #LVM_SETCOLUMN, ColumnNumber.l, @ColumnStyle)
This don't work (text is not right-aligned). What am I doing wrong ?
Change column style in ListIconView
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Manolo.
Hi,
You code is correct, but you need work in this order:
ColumnStyle.LV_COLUMN
ColumnStyle\imask = #LVCF_FMT
ColumnStyle\fmt = #LVCFMT_RIGHT
+
+
+
SendMessage_(GadgetID(#ListIconGadget), #LVM_SETCOLUMN, 4, @ColumnStyle)
SendMessage_(GadgetID(#ListIconGadget), #LVM_SETCOLUMN, 5, @ColumnStyle)
AddGadgetItem(#ListIconGadget,-1,"You text")
Best Regards,
Manolo
Hi,
You code is correct, but you need work in this order:
ColumnStyle.LV_COLUMN
ColumnStyle\imask = #LVCF_FMT
ColumnStyle\fmt = #LVCFMT_RIGHT
+
+
+
SendMessage_(GadgetID(#ListIconGadget), #LVM_SETCOLUMN, 4, @ColumnStyle)
SendMessage_(GadgetID(#ListIconGadget), #LVM_SETCOLUMN, 5, @ColumnStyle)
AddGadgetItem(#ListIconGadget,-1,"You text")
Best Regards,
Manolo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
If you try this with the left Column, you might get problems.
The MS Platform SDK says, that the alignment of the left comumn (index 0) can be changed.
However, it works on my system, and on some others too, so i guess it just works on the newer systems.
Officially it doesn't work
Timo
If you try this with the left Column, you might get problems.
The MS Platform SDK says, that the alignment of the left comumn (index 0) can be changed.
However, it works on my system, and on some others too, so i guess it just works on the newer systems.
Officially it doesn't work
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Manolo.
Hi gnozal,
One full manner to work in ListIconGadget:
Regards,
Manolo
Hi gnozal,
One full manner to work in ListIconGadget:
Code: Select all
;-Litle change of you LV_Colum to lvc
lvc.LV_COLUMN
lvc\imask = #LVCF_FMT
lvc\fmt = #LVCFMT_RIGHT
;-Init Constants
#TV_FIRST =$1100
#TVM_SETBKCOLOR =#TV_FIRST+29
#TVM_SETTEXTCOLOR =#TV_FIRST+30
#WindowIndex =0
#GadgetIndex =0
Procedure BubbleTip(bWindow.l,bGadget.l,bText.s)
ToolTipControl=CreateWindowEx_(0,"ToolTips_Class32","",$D0000000|$40,0,0,0,0,WindowID(bWindow),0,GetModuleHandle_(0),0)
SendMessage_(ToolTipControl,1044,0,0)
SendMessage_(ToolTipControl,1043,$DFFFFF,0)
SendMessage_(ToolTipControl,1048,0,180)
Button.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Button\uFlags=$11
Button\hWnd=GadgetID(bGadget)
Button\uId=GadgetID(bGadget)
Button\lpszText=@bText
SendMessage_(ToolTipControl,$0404,0,Button)
EndProcedure
;-Window Constants
#Window_Test = #WindowIndex:#WindowIndex=#WindowIndex+1
;Window_Test
#Gadget_Test_ListIcon2 = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_Test_Button3 = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_Test_Button4 = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
Procedure.l Window_Test()
If OpenWindow(#Window_Test,165,0,221,215,#PB_Window_SystemMenu|#PB_Window_Invisible,"Test ListIconGadget")
If CreateGadgetList(WindowID())
ListIconGadget(#Gadget_Test_ListIcon2,10,15,200,150,"Test 1",100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
SendMessage_(GadgetID(#Gadget_Test_ListIcon2),#LVM_SETBKCOLOR,0,7398114); Send background color
SendMessage_(GadgetID(#Gadget_Test_ListIcon2),#LVM_SETTEXTBKCOLOR,0,7398114); Send background color for text
SendMessage_(GadgetID(#Gadget_Test_ListIcon2),#LVM_SETTEXTCOLOR,0,16711680); Send the real color of text
AddGadgetColumn(#Gadget_Test_ListIcon2,1,"Test 2",70)
ButtonGadget(#Gadget_Test_Button3,10,175,60,20,"Align Rigth")
BubbleTip(#Window_Test,#Gadget_Test_Button3,"If push this button make the alignement to Rigth but redraw the contents of ListIcon")
ButtonGadget(#Gadget_Test_Button4,80,175,60,20,"Move Up")
BubbleTip(#Window_Test,#Gadget_Test_Button4,"If push this button, conbine align to rigth and all time view the last item add")
HideWindow(#Window_Test,0)
ProcedureReturn WindowID()
EndIf
EndIf
EndProcedure
cr.s=Chr(10)
If Window_Test()
;-Add datas in first instance
For i=1 To 12
AddGadgetItem(#Gadget_Test_ListIcon2,-1,"My Counter "+Str(i)+cr+Str(1)+".00")
Next
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_EventGadget
EventGadgetID = EventGadgetID()
Select EventGadgetID
Case #Gadget_Test_Button3 ; For redraw and align to rigth
ClearGadgetItemList(#Gadget_Test_ListIcon2);Clear the ListIconView
For i=1 To 12
AddGadgetItem(#Gadget_Test_ListIcon2,-1,"My Counter "+Str(i)+cr+Str(1)+".00")
Next
SendMessage_(GadgetID(#Gadget_Test_ListIcon2), #LVM_SETCOLUMN, 0, @lvc)
SendMessage_(GadgetID(#Gadget_Test_ListIcon2), #LVM_SETCOLUMN, 1, @lvc)
Case #Gadget_Test_Button4 ; For redran, align to rigth and send the last to top and down the rigth bar
LastItem=SendMessage_(GadgetID(#Gadget_Test_ListIcon2), #LVM_GETITEMCOUNT, 0, 0)
SendMessage_(GadgetID(#Gadget_Test_ListIcon2), #LVM_ENSUREVISIBLE, LastItem-1, 0)
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow And EventWindowID()=#Window_Test
CloseWindow(#Window_Test)
EndIf
Manolo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Denis.
Hi gnozal,
if you want to change column style when you want, you have to use the LVM_UPDATE message like this :
SendMessage_(GadgetID(#ListIconGadget),#LVM_UPDATE,first item,last item).
If you don't send this message, only the header will be aligned.
Here an exemple (running well under Win98 SE):
Denis
Hi gnozal,
if you want to change column style when you want, you have to use the LVM_UPDATE message like this :
SendMessage_(GadgetID(#ListIconGadget),#LVM_UPDATE,first item,last item).
If you don't send this message, only the header will be aligned.
Here an exemple (running well under Win98 SE):
Code: Select all
#MainWindow = 0#ListIconGadget1 = 1
If OpenWindow(#MainWindow,0,0,300,300,#PB_Window_ScreenCentered,"")
If CreateGadgetList(WindowID())
HwndListView = ListIconGadget(#ListIconGadget1,1,1,298,298,"Colonne 1", 298/4 ,#PB_ListIcon_MultiSelect)
If HwndListView
AddGadgetColumn(#ListIconGadget1, 1, "Colonne 2", 298/4)
AddGadgetColumn(#ListIconGadget1, 2, "Colonne 3",298/4)
AddGadgetColumn(#ListIconGadget1, 3, "Colonne 4",298/4)
EndIf
For i.b = 1 To 10
AddGadgetItem(#ListIconGadget1, -1, "111"+Chr(10)+ "222"+Chr(10)+"333"+Chr(10)+ "444")
Next i
EndIf
EndIf
MessageRequester("alignement à droite de la colonne 3","Appuyer sur Ok",16)
; aligne le texte de la 3ème colonne à droite
ColumnStyle.LV_COLUMN\imask = #LVCF_FMT
ColumnStyle\fmt = #LVCFMT_RIGHT
SendMessage_(GadgetID(#ListIconGadget1), #LVM_SETCOLUMN, 2, @ColumnStyle)
; c'est le message qui met à jour la liste
; le nombre total d'éléments est renvoyé par CountGadgetItems(#ListIconGadget1) auquel il faut retirer 1
; car l'index commence à 0
SendMessage_(GadgetID(#ListIconGadget1),#LVM_UPDATE,0,CountGadgetItems(#ListIconGadget1)-1)
Repeat
WaitWindowEvent()
Until WaitWindowEvent() = #PB_EventCloseWindow)-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Denis.
Gnozal,
with my exemple, if you compile it, you will have probleme to close the window because i don't use #PB_Window_SystemMenu
Modify like this
If OpenWindow(#MainWindow,0,0,300,300,#PB_Window_ScreenCentered |#PB_Window_SystemMenu,"")
Denis
Gnozal,
with my exemple, if you compile it, you will have probleme to close the window because i don't use #PB_Window_SystemMenu
Modify like this
If OpenWindow(#MainWindow,0,0,300,300,#PB_Window_ScreenCentered |#PB_Window_SystemMenu,"")
Denis