multiligne sur un listicongadget
multiligne sur un listicongadget
Salut
Je voudrais savoir comment fait on pour avoir des hauteurs de lignes différentes dans un listicongadget ?
Merci
Je voudrais savoir comment fait on pour avoir des hauteurs de lignes différentes dans un listicongadget ?
Merci
merci pour vos réponses, j'ai trouvé un code qui le fait mais j'avoue que je ne comprend pas grand chose et surtout je voudrais extraire que la possibilité d'avoir 2 lignes sur la listicongadget
qu'en pensez vous ?
qu'en pensez vous ?
apparemment c'est l'utilisation de sendmessage mais bon ?
qu'en pensez vous ?
Code : Tout sélectionner
;
; Basics for drawing a custom multiline ListIconGadget
; ****************************************************
; You can specify wordwrap for each column as necessary.
; Here I use wordwrap in Column 0 and single line with ellipsis (...) as needed.
; Still To-Do list:
; ------------------
; Support #PB_ListIcon_CheckBoxes
; Support #PB_ListIcon_AlwaysShowSelection
; Support #PB_ListIcon_MultiSelect
; Support icons
; --> Constants
#LVM_GETSUBITEMRECT = #LVM_FIRST + 56
#DT_WORD_ELLIPSIS = $40000
#DT_END_ELLIPSIS = $8000
#DT_PATH_ELLIPSIS = $4000
#DT_MODIFYSTRING = $10000
#CDIS_CHECKED = 8
#CDIS_DEFAULT = $20
#CDIS_DISABLED = 4
#CDIS_FOCUS = $10
#CDIS_GRAYED = 2
#CDIS_HOT = $40
#CDIS_INDETERMINATE = $100
#CDIS_MARKED = $80
#CDIS_SELECTED = 1
#CDIS_SHOWKEYBOARDCUES = $200
#CDDS_ITEM = $10000
#CDDS_MAPPART = 5
#CDDS_POSTERASE = 4
#CDDS_POSTPAINT = 2
#CDDS_PREERASE = 3
#CDDS_PREPAINT = 1
#CDDS_ITEMPOSTERASE = #CDDS_ITEM | #CDDS_POSTERASE
#CDDS_ITEMPOSTPAINT = #CDDS_ITEM | #CDDS_POSTPAINT
#CDDS_ITEMPREERASE = #CDDS_ITEM | #CDDS_PREERASE
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT
#CDDS_SUBITEM = $20000
#CDRF_DODEFAULT = 0
#CDRF_NEWFONT = 2
#CDRF_NOTIFYITEMDRAW = $20
#CDRF_NOTIFYPOSTERASE = $40
#CDRF_NOTIFYPOSTPAINT = $10
#CDRF_NOTIFYSUBITEMDRAW = $20
#CDRF_SKIPDEFAULT = 4
; --> Create assorted brushes for passing on to device context
Global Dim brush(4)
Enumeration
#C0Brush
#C1Brush
#C2Brush
#SelectedBrush
EndEnumeration
brush(#C0Brush) = CreateSolidBrush_(RGB(255, 155, 155)) ; column 0 brush
brush(#C1Brush) = CreateSolidBrush_(RGB(155, 255, 155)) ; column 1 brush
brush(#C2Brush) = CreateSolidBrush_(RGB(155, 155, 255)) ; column 2 brush
brush(#SelectedBrush) = CreateSolidBrush_(RGB(255, 255, 155)) ; selected row brush
; --> Windowcallback
Procedure myWindowCallback(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*nmhdr.NMHEADER = lparam
; --> Lock column 0 width
If *nmhdr\hdr\code = #HDN_ITEMCHANGING And *nmhdr\iItem = 0
result = #True
EndIf
*lvCD.NMLVCUSTOMDRAW = lparam
If *lvCD\nmcd\hdr\hwndFrom=GadgetID(0) And *lvCD\nmcd\hdr\code = #NM_CUSTOMDRAW
Select *lvCD\nmcd\dwDrawStage
Case #CDDS_PREPAINT
result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
result = #CDRF_NOTIFYSUBITEMDRAW;
Case #CDDS_ITEMPREPAINT | #CDDS_SUBITEM
thisItem = *lvCD\nmcd\dwItemSpec
; --> Define rect for text
subItemRect.RECT\left = #LVIR_LABEL
subItemRect.RECT\top = *lvCD\iSubItem
; --> Get the subitem rect
SendMessage_(GadgetID(0), #LVM_GETSUBITEMRECT, thisItem, @subItemRect)
subItemText$ = GetGadgetItemText(0, *lvCD\nmcd\dwItemSpec, *lvCD\iSubItem)
sitLen = Len(subItemText$)
Select *lvCD\iSubItem
Case 0
; --> Define text and background colors for column 0 and set Drawtext_() flags
lvFlags = #DT_END_ELLIPSIS | #DT_WORDBREAK;| #DT_MODIFYSTRING
; --> Paint over unused icon rect
subItemRect\left = 0
If GetGadgetState(0) = thisItem
; --> If item is selected, colorize column 0
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#SelectedBrush))
Else
; --> If item is not selected, colorize column 0
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#C0Brush))
EndIf
; --> Text color for column 0
SetTextColor_(*lvCD\nmcd\hDC, RGB(100, 0, 0))
Case 1
; --> Define text and background colors for column 1 and set Drawtext_() flags
lvFlags = #DT_END_ELLIPSIS | #DT_SINGLELINE | #DT_VCENTER
If GetGadgetState(0) = thisItem
; --> If item is selected, colorize column 1
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#SelectedBrush))
Else
; --> If item is not selected, colorize column 1
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#C1Brush))
EndIf
; --> Text color for column 1
SetTextColor_(*lvCD\nmcd\hDC, RGB(0, 100, 0))
Case 2
; --> Define text and background colors for column 2 and set Drawtext_() flags
lvFlags = #DT_END_ELLIPSIS | #DT_SINGLELINE | #DT_VCENTER
If GetGadgetState(0) = thisItem
; --> If item is selected, colorize column x
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#SelectedBrush))
Else
; --> If item is not selected, colorize column x
FillRect_(*lvCD\nmcd\hDC, subItemRect, brush(#C2Brush))
EndIf
; --> Text color for column x
SetTextColor_(*lvCD\nmcd\hDC, RGB(0, 0, 100))
EndSelect
; --> Adjust rect for text margins
subItemRect\left +3
subItemRect\right -3
subItemRect\bottom -3
; --> Draw our text
DrawText_(*lvCD\nmcd\hDC, subItemText$, sitLen, subItemRect, lvFlags)
result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 480, 260,"Sparkies Multiline ListIconGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
SetWindowCallback(@myWindowCallback())
CreateStatusBar(0, WindowID(0))
ListIconGadget(0, 10, 10, 470, 225, "Column 0", 150,#PB_ListIcon_FullRowSelect)
AddGadgetColumn(0, 1, "Column 1", 150)
AddGadgetColumn(0, 2, "Column 2", 150)
; --> Create a new imagelist (1x30) to increase row hieght
imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)
For a=0 To 9
addtext$ = "Locked Column 0 item #" + Str(a) + Chr(13) + "on 2 lines of text." + Chr(10) + "Column 1 item #" + Str(a) + " on 1 line" + Chr(10) + "Column 2 item #" + Str(a) + " on 1 line"
atLen = Len(addtext$)
AddGadgetItem(0,-1, addtext$)
Next
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case 0
; --> Display selected ListIconGadget index in statusbar
StatusBarText(0, 0, "Selected item index is: " + Str(GetGadgetState(0)))
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
EndIf
End
apparemment c'est l'utilisation de sendmessage mais bon ?
ça vient des exemples de Codearchive
English forum: http://www.purebasic.fr/english/viewtop ... highlight=
; Author: Sparkie (updated for PB 4.00 by Andre)
; Date: 06. December 2004
; OS: Windows
; Demo: No
; Basics for drawing a custom multiline ListIconGadget
; ****************************************************
; You can specify wordwrap for each column as necessary.
; Here I use wordwrap in Column 0 and single line with ellipsis (...) as needed.
Voila Monsieur
English forum: http://www.purebasic.fr/english/viewtop ... highlight=
; Author: Sparkie (updated for PB 4.00 by Andre)
; Date: 06. December 2004
; OS: Windows
; Demo: No
; Basics for drawing a custom multiline ListIconGadget
; ****************************************************
; You can specify wordwrap for each column as necessary.
; Here I use wordwrap in Column 0 and single line with ellipsis (...) as needed.
Voila Monsieur
Désolé contrairement à ce que je pensais initialement il suffit de mettre un Chr(13) dans la cellule pour séparer les deux ligne donc c'est bien possible !
Code : Tout sélectionner
AddGadgetItem(0,-1, "Ligne1"+Chr(13)+"Ligne2")
Dernière modification par brossden le mar. 17/juin/2008 11:42, modifié 1 fois.
Denis
Bonne Jounée à tous
Bonne Jounée à tous
Moi ça n'est pas Monsieur, mais Madame La vache espagnole qui est allé beuglé ici !
On va bien voir qu'est-ce qu'ils en pensent.
1) Soit pas de réponse
2) Soit il y en a un qui va écrire «et le post 6643 ? Tu l'as pas regardé ??»
3) Soit il y aura une réponse négative (on peut pas), dans ce cas, système D oblige.
4) Soit tu risques de voir apparaître un message positif, et là bingo!
Ollivier
On va bien voir qu'est-ce qu'ils en pensent.
1) Soit pas de réponse
2) Soit il y en a un qui va écrire «et le post 6643 ? Tu l'as pas regardé ??»
3) Soit il y aura une réponse négative (on peut pas), dans ce cas, système D oblige.
4) Soit tu risques de voir apparaître un message positif, et là bingo!
Ollivier