Subject RE: [IBO] Bug in IB_Grid - OnExit firing
Author Paul Hope
Hi Geoff - thanks for the reply

> Hi Paul,
>
> > I am changing the size of a grid OnEnter and reverting back
> > OnExit. If there is also something causing a layout change
> > and the focused field has an IBMemoEnh then OnExit fires
> and the size
> > reverts back although the grid still appears to have focus.
>
> Does the problem not happen with any other type of control in
> the grid?
>

In the demo the problem does not occur with an IB_memo but it does in the
real application - I havent quite sorted that one yet.

>
> If the problem happens with any control on the grid then...
>
> There have always been complications with controls embedded
> in a grid and focus detection. The reality is that focus has
> moved out of the grid and into the IBMemo and back again.
> Some of the code in ib_grid tries to ignore this distinction,
> but I cannot remember what happens for grid OnExit, OnEnter.
>
> If you look at TIB_CustomGrid.HasFocus you will see code that
> can be used to detect whether the grid or any of its child
> controls contains the focus or active control. (Regrettably
> that method is private, so you cant use it directly you would
> have to create your own copy.)
>

I'll have a look at that. I didn't think moving focus to a child control
cause an exit from the parent. I had hoped that the hierarchy of parenthood
would retain the focus for the grid - obviously not. In fact putting the
grid on a panel and using its OnEnter/OnExit gives exactly the same
behaviour.

>
> If the problem only happens with IBMemoEnh...
>
> In this case I suspect the problem could be that the API
> handle is being destroyed and recreated in order to alter
> certain properties of the control. (eg: When resizing a memo
> with auto scrollbars the control may decide that one or other
> scrollbar is required and recreate itself to achieve the
> desired change.)
>
> I have had various problems with automatic scrollbars on the
> MemoEnh. In some situations I have found the best way to
> achieve some level of stability is to fix the scrollbars as
> needed (either as both with wrap=false, or at vertical with
> wrap=true). This should stop the memo from making too many
> API changes as it changes size.
>
I must confess to not understanding you here. I assume it means that
looking at TIB_CustomGrid.HasFocus wont help. I'm thinking the problem is
too complex to be worth solving or the current situation is the best of an
imperfect world.

I shall have to have a rethink . . .

Regards
Paul