ListViewGadget and LB_SETTABSTOPS

Just starting out? Need help? Post your questions and find answers here.
zpenava
New User
New User
Posts: 1
Joined: Fri Oct 15, 2004 6:04 pm

ListViewGadget and LB_SETTABSTOPS

Post by zpenava »

Hi,

Can anyone please suggest me approach how to use LB_SETTABSTOPS message to set the tab-stop positions in a ListViewGadget in your application?

Thanks.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

First off, Welcome to PB zpenava :)

This is my first attempt at using LB_SETTABSTOPS, so this is just a first look. Optimizing the code is up to you. ;)

Tested and working on WinXPhome with PB 3.91.

Code: Select all

; --> array for 2 tabstops
Dim tStop(1)

If OpenWindow(0, 0, 0, 370, 180, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListViewGadget and TabStops") And CreateGadgetList(WindowID(0)) 
  
  ; --> We add the #LBS_USETABSTOPS flag to our ListViewGadget
  ListViewGadget(0, 10, 10, 350, 120, #LBS_USETABSTOPS)
  
  ButtonGadget(1, 10, 150, 100, 20, "Use Tabstops")
  AddGadgetItem (0,-1,"Mr. John Q. Public" + Chr(9) + "12345 His Street" + Chr(9) + "New York")   ; define listview content 
  AddGadgetItem (0,-1,"Mr. & Mrs. John Q. Public" + Chr(9) + "9876 Any Road" + Chr(9) + "Paris")   ; define listview content 
  AddGadgetItem (0,-1,"John & Mary Public" + Chr(9) + "258 Their St." + Chr(9) + "Sydney")   ; define listview content 
  
  ; --> Set our tabstops
  ; --> 1st tabstop is length of longest line in column 1 times 4
  tStop(0) = 25*4
  
  ; --> 2nd tabstop is (length of longest line in column 2 times 4) added To tStop(0)
  tStop(1) = tStop(0)+(16*4)
  
  Repeat
    event = WaitWindowEvent()
    Select event
      Case #PB_EventGadget
        Select EventGadgetID()
          Case 1
            
            ; --> use tabstops
            If GetGadgetText(1) = "Use Tabstops"
              SendMessage_(GadgetID(0), #LB_SETTABSTOPS, 2, @tStop(0))
              InvalidateRect_(GadgetID(0), 0, 1)
              SetGadgetText(1, "No Tabstops")
              
            ; --> don't use tabstops  
            Else
              SendMessage_(GadgetID(0), #LB_SETTABSTOPS, 0, 0)
              InvalidateRect_(GadgetID(0), 0, 1)
              SetGadgetText(1, "Use Tabstops")
            EndIf
            
        EndSelect
    EndSelect
    
  Until event = #PB_Event_CloseWindow 
EndIf 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

Thanks Sparkie for this information. I was struggling with the layout of ListViewGadget myself and your example did it. :D
I wonder why something like this isn't mentioned in the Helpfile of PB. Even the option to add flags is not mentioned. Your example made me look in the Win32 helpfile to discover the possibilities.
Post Reply