It is currently Thu Nov 23, 2017 12:07 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: ListIconGadget how to Wrap Words
PostPosted: Tue Nov 14, 2017 6:52 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 435
Location: china
ListIconGadget how to Wrap Words
Code:
If OpenWindow(0, 0, 0, 340, 200, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 ListIconGadget(0,  5,  5, 330, 190, "Column 1", 100)
 
 For b = 2 To 4
  AddGadgetColumn(0, b, "Column Wrap Words " + Str(b), 65)
 Next
 For b = 0 To 2
  AddGadgetItem(0, b, "Item Wrap Words 1"+Chr(10)+"Item Wrap Words 2"+Chr(10)+"Item Wrap Words 3"+Chr(10)+"Item Wrap Words 4")
 Next
 
 Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget how to Wrap Words
PostPosted: Thu Nov 16, 2017 11:14 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 377
Location: Berlin and Ibiza
http://www.rsbasic.de/aktualisierung/wi ... C3%A4ge.pb

_________________
ImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget how to Wrap Words
PostPosted: Fri Nov 17, 2017 12:07 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 435
Location: china
thanks RSBasic's file, but on my winXP , no Wrap Words...
================
this simplifyed from CodeArchiv:
Code:
; ListIcon_Multiline.pb
; English forum: http://www.purebasic.fr/english/viewtopic.php?t=13226&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.

; 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

; --> 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

              Case 1
                ; --> Define text and background colors for column 1 and set Drawtext_() flags
                lvFlags = #DT_END_ELLIPSIS | #DT_SINGLELINE | #DT_VCENTER
              Case 2
                ; --> Define text and background colors for column 2 and set Drawtext_() flags
                lvFlags = #DT_END_ELLIPSIS | #DT_SINGLELINE | #DT_VCENTER
            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())

  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 (1x70) to increase row hieght
  imageList = ImageList_Create_(1, 70, #ILC_COLOR32, 0, 70)
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)
  For a=0 To 9
    addtext$ = "Lock yyy yyyy ed 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
        EndSelect
    EndSelect
  Until event = #PB_Event_CloseWindow
EndIf
End

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget how to Wrap Words
PostPosted: Fri Nov 17, 2017 10:00 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 377
Location: Berlin and Ibiza
gurj wrote:
thanks RSBasic's file, but on my winXP , no Wrap Words...

Thank you for the information but Windows XP is 15 years old and obsolete.
That's why I don't mind that it doesn't work under Windows XP.

_________________
ImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIconGadget how to Wrap Words
PostPosted: Fri Nov 17, 2017 10:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 435
Location: china
sorry,
In Windows 7, there's no driver of my computer monitor

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye