IonicWind Software

IWBasic => General Questions => Topic started by: Andy on November 03, 2018, 06:16:37 am

Title: Listview position on window creation
Post by: Andy on November 03, 2018, 06:16:37 am
Hi,

Just adding some bells and whistles to the constants program and I can't understand why this is happening....

When the program loads, it gets the position of the listview from when you closed the program before e.g. position 6.
The program loads with a variable "DoFromLoad" set to 1.
In the window's handler I have this section....

Code Select
CASE& @LVNITEMCHANGED
      if DoFromLoad = 1   ' do on loading the program one time only
         DoFromLoad = 0
         setscrollpos(win,ListView,FirstPos*16)
         CONTROLCMD win,ListView,@LVSETSELECTED,FirstPos
         setfocus win,ListView
         LVpos = FirstPos
         return 0
     endif

     pos = 0
     Info = ""
     cValue = ""
     pos=*<NMLISTVIEW>@LPARAM.iItem
     CONTROLCMD(win,ListView,@LVGETTEXT,pos,0,Info)
     CONTROLCMD(win,ListView,@LVGETTEXT,pos,1,cValue)
     setcontroltext win,LastConstSelected,Info
     setcontroltext win,LastValueSelected,cValue
     LVpos = pos
     setfocus win,ListView


So the very first time on load, the listview is set to position 6, highlighted, and scroll bar in the correct position BUT when I press the down arrow key to move the selection on by one it jumps to position zero.

Any ideas please?

Thanks,
Andy.

Title: Re: Listview position on window creation
Post by: fasecero on November 03, 2018, 10:51:52 am

Maybe the listview uses the focused item after a keyboard event. Try defining one

Code Select
ListView_SetItemState(hwnd_listview, focus_index, LVNI_SELECTED | LVNI_FOCUSED, LVNI_SELECTED | LVNI_FOCUSED)