Notifications
Clear all
[Closed] listbox selection
Oct 15, 2014 6:37 am
How can I force focus on a particular item in listbox…or must I use a dot net listbox?
1 Reply
Oct 15, 2014 6:37 am
here is how to do it for mxs ListBox:
global listboxDialog_pos = unsupplied
try
(
listboxDialog_pos = getdialogpos listboxDialog
destroydialog listboxDialog
)
catch()
rollout listboxDialog "" width:200
(
local LB_GETTOPINDEX = 0x018E
local LB_SETTOPINDEX = 0x0197
local lb_height = 20
listbox lb width:190 height:lb_height pos:[5,5]
fn getTopIndex lb:lb =
(
(windows.sendMessage lb.hwnd[1] LB_GETTOPINDEX 0 0) + 1
)
fn setTopIndex index lb:lb =
(
windows.sendMessage lb.hwnd[1] LB_SETTOPINDEX (index - 1) 0
)
fn ensureIndex index lb:lb =
(
top = getTopIndex()
if top + lb_height < index do
(
top = amax 1 (index - lb_height)
windows.sendMessage lb.hwnd[1] LB_SETTOPINDEX top 0
)
)
on listboxDialog open do
(
lb.items = for k=1 to 40 collect (formattedprint k format:"04d")
ensureIndex 35 -- set item 35 to be sure visible in the list view
)
)
createdialog listboxDialog pos:listboxDialog_pos