Hi ...
I find that i have very weird problem with listbox.
I simply want recive position of selected item from listbox when i click or doubleclick
one item.
Here is code which constantly return -1 as position ,i read help twice... ???
'the listbox program
DEF w1:window
DEF pos:int
'open a window and add a menu
OPENWINDOW w1,0,0,600,400,@SIZE|@MINBOX|@MAXBOX|@CAPTION,0,"Lines",&mainwindow
SETWINDOWCOLOR w1,RGB(220,220,230)
CONTROL w1,@LISTBOX,"",4,60,160,150,0x50B00140,3
'add items
AddString w1,3,"0.item"
AddString w1,3,"1.item"
AddString w1,3,"2.item"
AddString w1,3,"3.item"
AddString w1,3,"4.item"
AddString w1,3,"5.item"
AddString w1,3,"6.item"
waituntil w1 = 0
end
SUB mainwindow
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
CASE @IDCONTROL
'.......................................
IF @CONTROLID=3
'F @NOTIFYCODE=0
'---------------------------------
pos=GETSELECTED(w1,3)
Move w1,10,10:Print w1,"POS:",str$(pos)
'---------------------------------
'ENDIF
ENDIF
' also try with ...
CASE @IDLBUTTONDBLCLK
pos=GETSELECTED(w1,3)
Move w1,10,10:Print w1,"POS:",pos
'.........................................
ENDSELECT
RETURN
ENDSUB
Aurel
You're missing a style flag
CONTROL w1,@LISTBOX,"",4,60,160,150,0x50B00140|@CTLISTNOTIFY,3
and I changed your handler just a little
SUB mainwindow
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
CASE @IDCONTROL
'.......................................
select @CONTROLID
case 3
select @NOTIFYCODE
case @LBNDBLCLK
case& @LBNSELCHANGE
'---------------------------------
pos=GETSELECTED(w1,3)
Move w1,10,10:Print w1,"POS:",str$(pos)
'---------------------------------
endselect
ENDselect
'.........................................
ENDSELECT
RETURN
ENDSUB
LarryMc
Oh my...
I feel that something missing ::)
Thank you Larry..again
I miss this from help:
Quote@CTLISTNOTIFY
Parent window receives an input message whenever the user clicks or double-clicks a string
I get that same program work with ENTER key:
'the listbox program
DEF w1:window
DEF pos:uint
'open a window and add a menu
OPENWINDOW w1,0,0,600,400,@SIZE|@MINBOX|@MAXBOX|@CAPTION,0,"Lines",&mainwindow
SETWINDOWCOLOR w1,RGB(220,220,230):BACKPEN w1,RGB(220,220,230)
Move w1,100,10:Print w1,"Select item then press ENTER..."
CONTROL w1,@LISTBOX,"",4,60,160,150,0x50B00140,3
SETCONTROLNOTIFY w1,3, TRUE, TRUE
'add items
AddString w1,3,"0.item"
AddString w1,3,"1.item"
AddString w1,3,"2.item"
AddString w1,3,"3.item"
AddString w1,3,"4.item"
AddString w1,3,"5.item"
AddString w1,3,"6.item"
waituntil w1 = 0
end
SUB mainwindow
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
CASE @IDCONTROL
'.......................................
IF @CONTROLID=3
IF @NOTIFYCODE=@ENENTERKEY
'---------------------------------
pos=GETSELECTED(w1,3)
Move w1,10,10:Print w1,"POS:",str$(pos)
'---------------------------------
ENDIF
ENDIF
'.........................................
ENDSELECT
RETURN
ENDSUBBut your option is far better ;)
Why i need this...
I want use this in first place in ABasic left side listbox to
highlite line in scintilla control.
So if user load code with many subs then when doublclick sub name in listbox
scintilla automaticly go to line where is this sub located...
And works on this way :
IF @CONTROLID=3
IF @NOTIFYCODE=@LBNDBLCLK
'---------------------------------
pos=GETSELECTED(w1,3)
Move w1,10,10:Print w1,"POS:",str$(pos)
'---------------------------------
ENDIF
ENDIFThanks ... :)
Aurel
I use a combox to do that in my current Visual Designer. In VD2 I will use a listview to do the same thing except it will contain ALL the subs in the entire project will be available.
Glad I could help you a little.
LarryMc