December 07, 2019, 11:14:11 pm

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Listview position on window creation

Started by Andy, November 03, 2018, 06:16:37 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

November 03, 2018, 06:16:37 am Last Edit: November 03, 2018, 06:27:58 am by Andy
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.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero


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)