Dear Sir
I use the following code to select the full row. But each time when I press Up or Down Arrow. EGrid32 will draw the current cell first. And then EGrid32 will draw the full row. How can I cancel the first draw current cell event ?
Function FRMBROWSEDATA_EGRDBROWSE_EGN_KEYUP (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
Local EGN As EgridNotify Ptr
EGN = lParam
sendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SELECTFULLROW, @EGN.CELL.Y, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_REFRESHALL, 0, 0)
Function =%true
End Function
I already got the solution from [support@egridpro.com]
function frmbrowsedata_egrdbrowse_egn_selectionchanged (ControlIndex as dword, HwndForm as dword, hEGrid as long, wParam as dword, lParam as long) as long
local EGN as EgridNotify ptr
local nCols as long
EGN = lParam
nCols = sendmessage (HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_GetMaxColumns, 0, 0)
@EGN.Selec.SX1 = 1
@EGN.Selec.SX2 = nCols
end function
That is logic and they gave you an elegant solution.
In fact, your solution was also good, but incomplete. Egrid32 automatically draws itself after user takes some actions in them, so, you need to tell Egrid32: 'Hey don't do what you normally do when i do this'.
You can do this by 'replying' to Egrid32 notifications with a non zero value.
For example, if Egrid32 sends you the %EGN_KEYDOWN notification, you can reply with a non-zero value. This is like saying: 'Thanks Egrid32, i will take it from here.'
Egrid32 will not do anything furter and let you take action manually. :)
So, all you needed to do was to tell Egrid32: 'Don't draw the selection automatically, i will draw it myself.'
Cool huh? This allows for a flexibility not found in other grid controls. :)
Elias,
In the initial solution KeyUp event is being replied with a non-zero value, %true, and the control is first redrawing the selection as the initial cell and then selects the entire row.
Am I missing something?
The cell selection is drawn before the EGN_KEYUP event. The EGN_KEYDOWN (or EGN_CLICKBEFORECLOSING) should return not null, Otherwise you experience the behaviour Roy was experiencing; drawing first the cell and then highlight the row, because the drawing of the cell's selection is drawn before the EGN_KEYUP event.
What i meant to say was that, in order to make Roy's method work, he only needed to return not null in EGN_CLICKBEFORECLOSING, or in EGN_KEYDOWN (I dont recall which one). But your method is better, because it requires putting code in only 1 function, instead of two.
:)
Actually.... i think this should do it as well:
Function FRMBROWSEDATA_EGRDBROWSE_EGN_CLICKBEFORECLOSING (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
Local EGN As EgridNotify Ptr
EGN = lParam
sendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SELECTFULLROW, @EGN.CELL.Y, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_REFRESHALL, 0, 0)
Function =%true '<---tell Egrid32 that we handled the situation manually, no more actions required.
End Function