Johan Sm
Delphi Developer |
Fri, 09 Jan 2004 17:14:52 GMT
Re:Emergency - Thread or Cache problem with Paradox
On Sun, 22 Jul 2001 10:34:07 -0400, "Sylvain Fortin" Quote<NoS...@sympatico.ca> wrote: > Thank you for taking the time to help me =). I would like to know if >DbiSaveChanges is available in the Standard Version of Delphi. This is the >list of uses included in my Main Form: >uses > Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, > ToolWin, ComCtrls, StdCtrls, DBTables, Db, Buttons, ImgList, > ExtCtrls, CommInt, inifiles, DBCtrls;
If you have the BDE, it should be there. Sorry, I should have said: add DBIProcs and that this works for TTables, but not TQueries. You did not state which you use. Quote>Also, I can't find find DbiSaveChanges in the help file, so I can't find in >wich library it is. Thank you very much and take care.
C:\Program Files\Borland\Common Files\BDE\BDE32.hlp on my system Here is an extract from Undu 9907087.htm: When testing a database application I had written, I noticed that occasionally a field would not be updated on closing the form, despite calling the dataset.post method in the OK button click event. All the other field updated fine, except one. To make life complicated, the field that would not update appeared to be selected at random each time I ran the program. This problem was not seen when the application was first written, only when I decided to make the interface a little more flash. After some more testing it became apparent that the field that did not get updated was the field that had the focus before I pressed the OK button. Furthermore, if I updated a field, then moved to a different field (that wasn't updated), then moved back and then pressed OK, the field was updated. After a bit of head scratching, I noticed that the OK button never received focus (it was not decended from TWinControl). Delving into the VCL, I found that data-bound controls update their underlying field during the LostFocus event. If I posted the dataset in the click event of a non-focused button, the control would never get the chance to update itself when it lost focus (when the form closed). The easiest solution was to replace the OK button with a control that could receive focus. Unfortunately, most good looking 3rd party buttons are like the delphi speed buttons and are not derived from TWinControl. I found rather a nice one on Torry (GradBtn by Harman) and have since sent him an improved version. This control can receive focus, but suprisingly is derived from TCustomControl. If you need to continue using a non-focusing button, you need to write some code in the click event that temporarily shifts focus away from the active control. I suppose you could sent a LostFocus message to the control but windows may not like that (where has the focus gone?). If anyone knows a way to force a control to update its underlying field, I would love to know. The second tricky bug I have seen also relates to non-updating of controls: Using TDataset.DisableControls and EnableControls is a great way to reduce unnecessary work by controls as you play with the underlying dataset. If you have ever stepped through a program, line by line, when the form loads and the controls react to data, it is amazing how much activity is involved. While the guides suggest you use these methods if you are scrolling through a dataset (something you should try to avoid anyway), I would recommend it if all you are doing is a seek / append. You can then enable the controls and put the dataset into edit mode and you are away. However, if you use TDataset.DisableControls before TDataset.Post, the record may not get updated properly. If you disable after the post, all is well. Regards Johan Smit
|