[WIN] Combo box: *Right*-Click select item?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Nov 01, 2000
- 546 views
Al, I've used your earlier suggestion for "right-click selects item in LIST box", and was trying to alter it to allow the same in a COMBO box, & ran into some difficulty. I can't find parallels for one of the API constants that you used for list box to apply for *combo box*, specifically CB_GETTOPINDEX. I looked at the API reference that Renzo Beggia provided recently, and while I was able to find a reference to CB_GETTOPINDEX, at I couldn't find the *value* it is supposed to be, to use. Can you think of some work-around that would allow right-click to select an item in a combo box's list? I've included your suggestion for right-click on *list* box below, for reference. Dan Moyer <code follows:> --Here's a solution to right click list box selection: ----------------------------------------------------------------------- include Win32Lib.ew constant Desktop=0 constant Window1= create(Window,"Test LB right clicks",Desktop,10,10,580,460,0) constant ListBox2=create(List,"2",Window1,40,20,260,200,0) --test listbox demo items: for j=1 to 30 do addItem(ListBox2,"entry"&sprintf("%d",j)) end for --define constants if not already defined in Win32Lib.ew: constant LB_GETITEMHEIGHT=#01A1, LB_GETTOPINDEX=#018E -- LB_SETCURSEL=#0186 --include an onMouse event in your program code: procedure onMouse_ListBox2(integer event, integer x, integer y) --insert event code here: atom lParam,index,bool,height,topindex,indexoffset sequence itemtext if event=RIGHT_DOWN then height=sendMessage(ListBox2,LB_GETITEMHEIGHT,0,0) topindex=sendMessage(ListBox2,LB_GETTOPINDEX,0,0) indexoffset=floor(y/height) index=indexoffset+topindex bool=sendMessage(ListBox2,LB_SETCURSEL,index,0) itemtext=getItem(ListBox2,index+1) --printf(1,"%s\n",{itemtext}) --unrem to print values --put any further processing code here: -- end if end procedure onMouse[ListBox2]=routine_id("onMouse_ListBox2") --may have to modify this last line for your version of Win32Lib: WinMain(Window1,Normal) ------------------------------------------------------------------ <code ends.> Good luck with it. Al Getz