Subject Re: [IBO] Trouble with TDateTimeEnh
Author Geoff Worboys
Hi Paul,

Last things first...
> I'm using WIN 2000 pro sp4 but have tried it on XP sp2 with
> IBO 4.3Aa and it worked fine - cant resolve between IBO
> version and operating system.

I compiled under XP sp2, Delphi6 and then ran the result under
W2K SP4 (a virtual machine with SP4 but none of the more recent
patches installed) - it worked fine.

Then I got your already compiled executable and there was the
problem exactly has you describe, this under XP sp2.

So when you compile it under Delphi6, IBO 4.7.16, Win2K SP4
etc the problem occurs whether the code is executed under
Win2K or WinXP. When I compile it the problem does not occur.

Me thinks it could be time to check out your installation.

. Make sure you are using the "Update Pack 2" for Delphi6.

. Try removing all temporary build files and rebuilding

. Check/remove all old versions of IBO from anywhere they
could be found by Delphi during a build.

. I've never needed to, but perhaps even try removing IBO
completely from the system and re-installing.

. You may need to check that no other installed libraries
replaced/patched or otherwise changed the VCL.

. not really sure what else to try, I've double checked all
my code and cannot find any differences from the base
code that could cause these focus changes (or lack of).

> I found the following line ( marked //+++++++++++ ) in
> IB_Grid seems to fix it but I have no idea if it may have
> other implications

> function TIB_CustomGrid.PositionControl

That is an interesting find. It confirms that the VCL thinks
that the grid (or something on it) still has the focus (see the
HasFocus check at the start).

I do not think the SetFocus call you have installed is safe
for generic use. The line occurs in a loop going through all
controls - there can be more than one, and in such cases the
the results of your additional SetFocus directly to the grid
may be unpredictable (actually it is probably predictable, just
too complicated to be bothered explaining ;-).

At the bottom of the loop code (outside the loop) you could try
to install (see earlier comments in the code about the form

if not Result then // if no dropped control was matched
tmpForm := GetParentForm( Controls[ ii ] );
if CanFocus and // and grid can be focused
(tmpForm <> nil) and // and form is defined
tmpForm.Visible and // and visible
tmpForm.Enabled then // and enabled

That is probably safe, although before doing that I would be
interested to have you put in some debugging code that
discovers exactly what is considered to be focused/active at
that point in the code. In theory it should not be the
date control or any part of it, but in practise perhaps the
VCL still has some residue.

This would be a last resort, first see if you can find an
installation reason for the difference.

Geoff Worboys
Telesis Computing