RE: EuGrid - Phil Russel
- Posted by Phil Russell <pg_russell at lineone.net> Jan 09, 2003
- 466 views
Jonas, Yep - you're quite right. There is a bug in the EGW_LoadData routine which means that the current cell is not reset to something sensible when the dataset is replaced. I will fix this in the next release, but in the meantime there is a simple workaround that you can use (see code following - the fix is in the DepClearPB_onClick routine). HTH, Phil -- Beginning of code include Win32Lib.ew include eugrid.ew without warning atom dep_opt_col, dep_desc_col, rtn_code, void --------------------------------------------------------- constant DepWin = createEx( Window, "Object Dependencies", 0, 10, 10, 550, 500, {WS_DLGFRAME, WS_SYSMENU}, {WS_EX_DLGMODALFRAME} ) constant DepGC = EGW_CreateGrid( DepWin, 10, 10, 532, 408, True) dep_opt_col = EGW_AddColumn(DepGC, "Option", 132, EGW_LAST, EGW_EDIT, 1) rtn_code = EGW_SetColumnProperty(DepGC, dep_opt_col, EGW_COL_MAXCHARS, 10) dep_desc_col = EGW_AddColumn(DepGC, "Description", 350, EGW_LAST, EGW_STATIC, 2) constant DepClearPB = createEx( DefPushButton, "Clear", DepWin, 10, 430, 90, 30, 0, 0) constant DepCancelPB = createEx( PushButton, "Cancel", DepWin, 110, 430, 90, 30, 0, 0) procedure DepWin_onOpen (integer self, integer event, sequence params) sequence dep_data dep_data = {{"Test","Test Description"}} rtn_code = EGW_LoadData(DepGC, dep_data, EGW_REPLACE) end procedure setHandler(DepWin, w32HOpen, routine_id("DepWin_onOpen")) procedure newDependent() sequence cell integer row -- Get currently selected cell cell = EGW_GetCurrentCell(DepGC) -- If ok to exit current cell if not sendMessage(DepGC, EGW_CELLCHANGE, cell[1], cell[2]) and not sendMessage(DepGC, EGW_ROWCHANGE, cell[1], cell[2]) then rtn_code = EGW_AddDataRow(DepGC, {"", ""}, EGW_LAST) repaintWindow(DepGC) void = EGW_ScrollToCell(DepGC, rtn_code, dep_opt_col) repaintWindow(DepGC) end if end procedure procedure DepGC_onEvent(integer self, integer event, sequence parms) atom msg, wParam, lParam, row_count sequence check_users, msgs, user_info, user_desc, user_grp, user, cur_cell, tv_select object row_data, rtn_obj msg = parms[1] wParam = parms[2] lParam = parms[3] if msg = EGW_CELLCHANGE then cur_cell = EGW_GetCurrentCell(DepGC) if cur_cell[1] > 0 then void = EGW_SaveCellData(DepGC, EGW_GetCurrentCell(DepGC)) end if elsif msg = EGW_LASTCELLTAB then newDependent() returnValue(True) end if end procedure setHandler(DepGC, w32HEvent, routine_id("DepGC_onEvent")) procedure DepClearPB_onClick (integer self, integer event, sequence params)--params is () sequence dep_data dep_data = {{"Test","Test Description"}} rtn_code = EGW_LoadData(DepGC, dep_data, EGW_REPLACE) --***START WORKAROUND Phil Russell 9/1/03 --Reset current cell to void cell rtn_code = EGW_SetCurrentCell(DepGC, -1, -1) --***END WORKAROUND Phil Russell 9/1/03 repaintWindow(DepGC) end procedure setHandler(DepClearPB , w32HClick, routine_id("DepClearPB_onClick")) procedure DepCancelPB_onClick (integer self, integer event, sequence params)--params is () closeWindow(DepWin) end procedure setHandler(DepCancelPB, w32HClick, routine_id("DepCancelPB_onClick")) WinMain( DepWin,Normal )