ListIconGadget - Multiline Entry

Just starting out? Need help? Post your questions and find answers here.
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ListIconGadget - Multiline Entry

Post by Phantomas »

How I can add multiline support in this code?

Code: Select all

Enumeration
  #window_jor
  #list_jor_errors
EndEnumeration

If OpenWindow(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)
 
  ListIconGadget(#list_jor_errors, 5, 5, 410, 230, "Time", 60, #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(#list_jor_errors, 1, "Text", 340)
 
  imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
  SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)
 
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
 
  HideWindow(#window_jor, 0)
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(#window_jor)
        Break
    EndSelect
  ForEver
EndIf
And how to remove left indention (if selected):
Image
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ListIconGadget - Multiline Entry

Post by Phantomas »

Anyone?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget - Multiline Entry

Post by RASHAD »

Hi
1- For MultiLine support search the forum for Sparkie code
2- For removing left indention next is a workaround

Code: Select all


Enumeration
  #window_jor
  #list_jor_errors
EndEnumeration

If OpenWindow(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)

  ContainerGadget(0,5,5,410,230,#PB_Container_Single)
  LI = ListIconGadget(#list_jor_errors, -5, 0, 410, 230, "  Time", 60, #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(#list_jor_errors, 1, "Text 1", 345)
  CloseGadgetList()
  imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
  SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)


  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")

  HideWindow(#window_jor, 0)

  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(#window_jor)
        Break
    EndSelect
  ForEver
EndIf

Egypt my love
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ListIconGadget - Multiline Entry

Post by Phantomas »

In Sparkie code much spare, need to only multiline example :(.
For removing left indention next is a workaround
Hah, strange method, I think WinAPI can help in this...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget - Multiline Entry

Post by RASHAD »

Another strange method

Code: Select all

Enumeration
  #window_jor
  #list_jor_errors
EndEnumeration

If OpenWindow(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)

  ListIconGadget(#list_jor_errors, 5,5, 410, 230, "  Time", 0, #PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
  AddGadgetColumn(#list_jor_errors, 1, "Text 1", 60)
  AddGadgetColumn(#list_jor_errors, 2, "Text 2", 340)
  imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
  SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)

  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")

  HideWindow(#window_jor, 0)

  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(#window_jor)
        Break
    EndSelect
  ForEver
EndIf

Code: Select all

Enumeration
  #window_jor
  #list_jor_errors
EndEnumeration

Global Dim FixColumn(3)

Procedure WinCB(hWnd, msg, wParam, lParam)
    Result = #PB_ProcessPureBasicEvents
   
    If msg = #WM_NOTIFY
         *nhdr.NMHEADER = lParam
         If *nhdr\hdr\code=#HDN_ITEMCHANGING
           If FixColumn(*nhdr\iItem)
              *npos.HD_ITEM = *nhdr\pitem
              *npos\cxy=0
           EndIf
         EndIf
      EndIf
      
    ProcedureReturn Result
   
EndProcedure

If OpenWindow(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)
  SetWindowCallback(@WinCB())
  LI = ListIconGadget(#list_jor_errors, 5,5, 410, 230, "", 60, #PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
  AddGadgetColumn(#list_jor_errors, 1, "Text 1", 60)
  AddGadgetColumn(#list_jor_errors, 2, "Text 2", 340)
  imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
  SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)

  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1,Chr(10)+ FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  SendMessage_(LI, #LVM_SETCOLUMNWIDTH,0,0)
  FixColumn(0) = 1
  HideWindow(#window_jor, 0)

  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(#window_jor)
        Break
    EndSelect
  ForEver
EndIf
Egypt my love
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ListIconGadget - Multiline Entry

Post by Phantomas »

Maybe anyone can get me normal method (WinAPI code) for multiline support in ListIconGadget? My same code:

Code: Select all

    Enumeration
      #window_jor
      #list_jor_errors
    EndEnumeration

    If OpenWindow(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)

      ListIconGadget(#list_jor_errors, 5, 5, 410, 230, "Time", 60, #PB_ListIcon_FullRowSelect)
      AddGadgetColumn(#list_jor_errors, 1, "Text", 340)

      imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
      SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)

      AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
      AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
      AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
      AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")

      HideWindow(#window_jor, 0)

      Repeat
        Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
            CloseWindow(#window_jor)
            Break
        EndSelect
      ForEver
    EndIf
Please, very need it...
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: ListIconGadget - Multiline Entry

Post by Sparkie »

No API needed for Windows 7 with XP skins Enabled.

@Phantomas: What version(s) of windows are you targeting?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Re: ListIconGadget - Multiline Entry

Post by Sparkie »

This is as thin as it gets for API induced multiline text. :wink:

Code: Select all

Enumeration
  #window_jor
  #list_jor_errors
EndEnumeration

; --> Get system brushes 
Global hiLightBrush = GetSysColorBrush_(#COLOR_HIGHLIGHT)
Global defaultBrush = GetSysColorBrush_(#COLOR_WINDOW)

Procedure myWindowCallback(hwnd, msg, wParam, lParam) 
  result = #PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_NOTIFY 
      *nmhdr.NMHEADER = lParam 
      *lvCD.NMLVCUSTOMDRAW = lParam 
      If *lvCD\nmcd\hdr\hwndFrom=GadgetID(#list_jor_errors) 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(#list_jor_errors), #LVM_GETSUBITEMRECT, thisItem, @subItemRect) 
            subItemText$ = GetGadgetItemText(#list_jor_errors, *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
                ; --> Paint over unused icon rect 
                subItemRect\left = 0 
                If GetGadgetState(#list_jor_errors) = thisItem 
                  ; --> If item is selected, colorize column 0 
                  FillRect_(*lvCD\nmcd\hdc, subItemRect, hiLightBrush)
                Else 
                  ; --> If item is not selected, colorize column 0 
                  FillRect_(*lvCD\nmcd\hdc, subItemRect, defaultBrush)
                EndIf 
                ; --> Text color for column 0 
                ;SetTextColor_(*lvCD\nmcd\hdc, #Green)
              Case 1 
                ; --> Define text and background colors for column 1 and set Drawtext_() flags 
                lvFlags = #DT_END_ELLIPSIS | #DT_WORDBREAK 
                If GetGadgetState(#list_jor_errors) = thisItem 
                  ; --> If item is selected, colorize column 0 
                  FillRect_(*lvCD\nmcd\hdc, subItemRect, hiLightBrush)
                Else 
                  ; --> If item is not selected, colorize column 0 
                  FillRect_(*lvCD\nmcd\hdc, subItemRect, defaultBrush)
                EndIf 
                ; --> Text color for column 1 
                ;SetTextColor_(*lvCD\nmcd\hdc, #Black)
            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(#window_jor, #PB_Any, #PB_Any, 420, 240, "PW Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible)
  SetWindowCallback(@myWindowCallback())
  ListIconGadget(#list_jor_errors, 5, 5, 410, 230, "Time", 60, #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(#list_jor_errors, 1, "Text", 340)
  
  imageList = ImageList_Create_(1, 30, #ILC_COLOR32, 0, 30)
  SendMessage_(GadgetID(#list_jor_errors), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)
  
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  AddGadgetItem(#list_jor_errors, -1, FormatDate("%hh:%ii:%ss", Date() + 10) + Chr(10) + "String" + Chr(13) + "String")
  
  HideWindow(#window_jor, 0)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(#window_jor)
        Break
    EndSelect
  ForEver
EndIf
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

Re: ListIconGadget - Multiline Entry

Post by Phantomas »

Sparkie wrote:No API needed for Windows 7 with XP skins Enabled.

@Phantomas: What version(s) of windows are you targeting?
I'm use WinXP, style does not affect... Windows 7 is strange.

Thank you for code!
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 639
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: ListIconGadget - Multiline Entry

Post by captain_skank »

Sorry to bump this thread.

Using the code above is there a way to show the dividing lines ( grid ) ??

Cheers
Post Reply