PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Marc Van Cauwenberghe on September 04, 2007, 10:26:40 AM

Title: EGRID AND FF
Post by: Marc Van Cauwenberghe on September 04, 2007, 10:26:40 AM
Hello Elias or Paul,

Problem:
I want a form to close as soon as someone clicks a row in an egrid control that is located on that form. When I do this it will produce a program error!!!

Just open a FF project, put an egrid control on it and

Function FORM1_EGRID321_EGN_CELLLEFTCLICK (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
   ... code ... code ...
   ... code ... code ...
   FF_CloseForm HwndForm
End Function


You will see what I mean.

Please help me, need this quick, new deadline  :'( :o :'(.

Marc

P.S. Sorry for the urgency...........


Title: Re: EGRID AND FF
Post by: Elias Montoya on September 04, 2007, 04:25:04 PM
Hello Mark, Yes, i see what you mean, the crash. But this is documented. ;)

From help File for EGN_CELLLEFTCLICK:

QuoteComments:
If The notification message returns TRUE, then no further actions will be taken, by default Egrid32 sends this message to Parent before performig the selection, but if Notification returns true, the selection will be cancelled.

The problem is that the notification is returning FALSE, so, Egrid32 is assuming everything is still fine, and tries to perform a cell selection as usual, but, in a grid that is most likely already deleted. This causes that Egrid32 tries to access memory blocks that are already freed.

Try this solution:

Function FORM1_EGRID321_EGN_CELLLEFTCLICK (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
   ... code ... code ...
   ... code ... code ...
   FF_CloseForm HwndForm
   
   FUNCTION = %TRUE

End Function


Added:
For more information, there is a topic named "Data Modification" wich talks exactly about this.

And from "How to find Bugs":

Situation #1: - You are getting a crash when processing a notification message yourself.

This one can be annoying, i know. First of, make sure you are not modifying data that Egrid32 asumes that will be available after you process the notification message. If Egrid32 tries to access objects that you delete during the notification message, there is a high posibility that Egrid32 will complain. This can also happen if you modify -and not necessarily delete- something that Egrid32 Expects to find unchanged. For example, if you set a wrong internal selection during a selection notification. Or if you resize grid during an internal resizement of the grid.

Some notification messages can be returned with a TRUE (or some other values, depending in the notification message), to bypass what Egrid32 was going to do when notification message returned, so, if you are modifying something that you know Egrid32 will try to change after the notification message returns, its a good idea to answer to Egrid32's notification messages properly. Good comunication between Egrid32 and the parent dialog is the key!.

:)
Title: Re: EGRID AND FF
Post by: Marc Van Cauwenberghe on September 04, 2007, 04:41:51 PM
Elias,

I wish I had 1/100 of your knowledge  :'( :'( :'( :'(

Anyway thank you, it works.

Marc
Title: Re: EGRID AND FF
Post by: Elias Montoya on September 04, 2007, 04:45:43 PM
 :o ;D :D