Re: Win32Lib: listbox: select item with RIGHT mouse click?

new topic     » goto parent     » topic index » view thread      » older message » newer message

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)

------------------------------------------------------------------

Good luck with it.
  Al Getz

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu