June 14, 2021, 03:56:33 AM


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

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....

      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

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