Skip navigation.

Lolek blog

Everything and nothing...

[c++] borland builder canfocus problem

, , , , , ,

Hi there,
today i want to share with you something that i had discovered today. During my work i got some problems with setting the focus on specified component... well sometimes i got access violation,and that kind of stuff...
The problem could be solved through method that is implemented in all components/objects that are inherited from twincontrol... called CanFocus()... the problem is that this method has also some problems with borland frames... so, the only way is to write your own function to get the same behaviour of the original one...
so, if you're looking to solve problem as mine.. read below to find out the source code...

ok, the function is very simple...
the only thing we need to know is if the element can have focus it must be... Visible and Enabled... and.. all it's parents should have those properties set in the same way... (enabled)
the second thing is, if we want to have the same functionality it should accept all object that inherits from twincontrol and should return bool value (true/false)... so here it is:

bool CanWeFocusIt(TWinControl *control)
{
  while(control)
  {
    if(!control->Enabled || !control->Visible)
    {
      return false;
    }
    control = control->Parent;
  }
  return true;
}


that's it... nothing more.. i hope i helped someone..

telefony dotykowe pisanie smsow table manager - simple table, keyboard manipulation

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies