August 09, 2020, 08:59:26 am


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.


November 03, 2018, 06:16:37 am Last Edit: November 03, 2018, 06:27:58 am by Andy

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
      if DoFromLoad = 1   ' do on loading the program one time only
         DoFromLoad = 0
         CONTROLCMD win,ListView,@LVSETSELECTED,FirstPos
         setfocus win,ListView
         LVpos = FirstPos
         return 0

     pos = 0
     Info = ""
     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?


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


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)