1. [WIN] Combo box: *Right*-Click select item?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Nov 01, 2000
- 568 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
2. Re: [WIN] Combo box: *Right*-Click select item?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Nov 01, 2000
- 555 views
Al, I *might* have halfway answered my own question, in that I found a value that might be correct: CB_GETTOPINDEX = #015B ; but when I *use* it, the routine doesn't actually respond to right click *in the list* portion of the combo box, but will respond to right-clicks in the *edit* box portion, and it then just sets the edit box to whatever the top item in the list is. Any useful thoughts?? Dan P.S. Found that value in an ".h" file on a MS Visual C++ disk I got once & could *never* make any sense of at all. ----- Original Message ----- From: "Dan B Moyer" <DANMOYER at prodigy.net> To: "Euphoria Mail List" <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Wednesday, November 01, 2000 5:19 AM Subject: [WIN] Combo box: *Right*-Click select item? > 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, > http://msdn.microsoft.com/library/psdk/buildapp/win32api_7f8p.htm > and while I was able to find a reference to CB_GETTOPINDEX, at > http://msdn.microsoft.com/library/psdk/winui/combobox_5hko.htm > > 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 > >