I've noticed that if a form with data aware controls is closed from the title bar and the active control has had its data changed that change never makes it into the underlying data source. I've traced this to the CM_EXIT message never getting fired for the control.
How can I ensure that no matter which control last had focus these changes get pushed to the data source?
You could send the needed CM_Exit in the OnCloseQuery event of your form.
procedure TMyForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Assigned(ActiveControl) then
SendMessage(ActiveControl.Handle, CM_EXIT,0,0);
end;