I'm porting a large delphi 1 program to D2, and all was well, but
a certain window won't create, and gives the message
' Cannot focus a disabled or invisible window '
Nowhere in my code I'm explicitly making things disabled or invisible
before the warning comes. I saw some other people having problems
with this one too, but no real solutions.
I get this when I do MyEdit.SetFocus in my FormCreate event. Use this instead
try MyEdit.SetFocus; except end;
Hope this helps.
>Hi,
> I'm porting a large delphi 1 program to D2, and all was well, but
>a certain window won't create, and gives the message
>' Cannot focus a disabled or invisible window '
>Nowhere in my code I'm explicitly making things disabled or invisible
>before the warning comes. I saw some other people having problems
>with this one too, but no real solutions.
This problem usually appears when you assign a control to the
ActiveControl property of a form. If the form's visible property is
False when you create it, the exception you describe will be
triggered.
I guess you could say it is a bug in Delphi.
Hope this helps!
Eric G.V. Fookes ===============<foo...@sc2a.unige.ch>==============
Creator of Delphi (1 & 2) Labeled Input Controls. Download from...
http://www.unige.ch/sciences/terre/geologie/fookes/delphi.htm
====================================================================
> This problem usually appears when you assign a control to the
> ActiveControl property of a form. If the form's visible property is
> False when you create it, the exception you describe will be
> triggered.
I fix it with TForm( owner ).show.
Anybody got something cleaner?
_
| | | _ _ http://www.stud.ntnu.no/~olavb/
|_| |_|_|_|_| mailto:Ol...@dds.nl
Eyecom Images, Amsterdam
I found it (only after getting down to the VCL-source code). My
application has a main window, and starts other windows from there, from which
other windows got created.
When creating these dialogs the creating window sets itself as parent of the
dialog. Then the VCL tries to set focus to one of the buttons, but raises
an exception because it thinks the main window is the parentform of the
button, and not the dialog. (GetParentForm function).
This is because the VCL iterates through te parents, until there is no more
parent. When this one is reached it supposes it is a form. That is correct,
but earlier in the parentlist the right form is passed. For an easy fix I
hacked the VCL, so that it stops at the first form. All is well since.
Thanks a lot for your reactions.
Robert
> Hi,
> I'm porting a large delphi 1 program to D2, and all was well, but
> a certain window won't create, and gives the message
> ' Cannot focus a disabled or invisible window '
> Nowhere in my code I'm explicitly making things disabled or invisible
> before the warning comes. I saw some other people having problems
> with this one too, but no real solutions.
Hi Robert.
I had this problem in D1 in designing state, when I tried to set the
forms ActiveControl property to a component, which was located in a
notebook page, which was not the active page at this moment. Actually
it typed the name of the component instead selecting it from the
combobox in the object inspector.
Maybe it helps.
Greets, Markus
___________________________________________________________________
| | |
| Markus Peters | "Vertrauen Sie mir - |
| m.pe...@koan.de | ich weiss, was ich tue" |
| http://www.koan.de/~m.peters/ | Sledge Hammer |
|_____________________________________|____________________________|