set listviewgadget text entry without scrolling (windows)

Share your advanced PureBasic knowledge/code with the community.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

set listviewgadget text entry without scrolling (windows)

Post by blueznl »

Code updated for 5.20+

loads of sweat before i found out what 'autoscrolled' (ahum) my (changing) listviewgadgets...

solution is easy:

Code: Select all

Procedure x_setlistviewitemtext(gadgetnr,itemnr,text.s)
  Protected t, gadget_h
  ;
  ; *** set specific item of a listview gadget to a new text
  ;
  ; in:             gadgetnr - gadgetid
  ; retval:                  - none
  ; out:                     - none
  ;
  ; note:
  ;
  ; - listviewgadget only
  ; - as setgadgetitemtext however does not scroll up or down
  ;
  ; listviewgadgets can scroll up / down when overwriting an entry (this is due to the behaviour of the
  ; gadget under windows, where an entry is replaced by first sending a delete message causing the scroll,
  ; followed by an insert item message)
  ;
  gadget_h = GadgetID(gadgetnr)
  t = SendMessage_(gadget_h,#LB_GETTOPINDEX,0,0)
  SendMessage_(gadget_h,#WM_SETREDRAW,#False,0)
  SetGadgetItemText(gadgetnr,itemnr,text,0)
  SendMessage_(gadget_h,#LB_SETTOPINDEX,t,0)
  SendMessage_(gadget_h,#WM_SETREDRAW,#True,0)
EndProcedure
this also minimizes 'flicker', though only without the last line in sight (don't ask me why, windows....)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )