if file('test_multiselect.dbf') // drop table test_multiselect endif if not file('test_multiselect.dbf') create table test_multiselect (id autoinc,data character(10)) use test_multiselect generate 10 use endif ** END HEADER -- do not remove this line // // Generated on 2014/02/18 // parameter bModal local f f = new test_multigridselectForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class test_multigridselectForm of FORM with (this) onOpen = class::FORM_ONOPEN onClose = class::FORM_ONCLOSE height = 18.9091 left = 68.4286 top = 1.5909 width = 45.5714 text = "" endwith this.CHILDTEST1 = new QUERY() this.CHILDTEST1.parent = this with (this.CHILDTEST1) left = -0.2857 top = 0.0455 sql = 'select * from "test_multiselect.DBF"' active = true endwith this.GRID1 = new GRID(this) with (this.GRID1) onOpen = class::GRID1_ONOPEN onMouseOver = class::GRID1_ONMOUSEOVER onMouseOut = class::GRID1_ONMOUSEOUT dataLink = form.childtest1.rowset multiSelect = true height = 10.6364 left = 4.0 top = 2.8636 width = 36.5714 endwith this.PUSHBUTTON1 = new PUSHBUTTON(this) with (this.PUSHBUTTON1) onClick = class::PUSHBUTTON1_ONCLICK height = 1.7727 left = 15.1429 top = 14.9545 width = 15.2857 text = "Clear selection" endwith this.TEXTLABEL1 = new TEXTLABEL(this) with (this.TEXTLABEL1) height = 1.0 left = 16.1429 top = 0.8636 width = 12.2857 text = "Select records" endwith this.rowset = this.childtest1.rowset function GRID1_onMouseOut(flags, col, row) // class::setcontrolkey(0,1) //release control key return function GRID1_onMouseOver(flags, col, row) // class::setcontrolkey(1,0) //hold down contol key return function GRID1_onOpen class::deselectEntry() return function PUSHBUTTON1_onClick local aGrid aGrid = new array() aGrid = form.grid1.selected() for n = 1 to aGrid.size form.rowset.goto(aGrid[n]) class::deselectEntry() next form.rowset.first() class::deselectEntry() return function form_onClose class::setcontrolkey(0,1) //make quite sure control key is released return function form_onOpen #include winuser.h if type("SendMessage") # "FP" extern clong SendMessage(chandle,cuint,clong,clong) user32 ; from "SendMessageA" endif if type("GetKeyboardState") # "FP" extern CVOID GetKeyboardState(CPTR) User32 endif if type("SetKeyboardState") # "FP" extern CVOID SetKeyboardState(CPTR) User32 endif return function setcontrolkey(onoff,nstate) local keybuffer,state keybuffer = Space(256) GetKeyboardState(keybuffer) state=keybuffer.getbyte(vk_control) If onoff # 0 nstate=bitor(128,state) endif keybuffer.setbyte(vk_control,nstate) SetKeyboardState(keybuffer) return state function deselectEntry local point class::setcontrolkey(1,0) sendmessage(form.grid1.hwnd,wm_lbuttondown,9,0x220018) sendmessage(form.grid1.hwnd,wm_lbuttonup,9,0x220018) class::setcontrolkey(0,1) return endclass