Board index » delphi » Master/Detail Form - Error: Cannot Focus a disabled or invisible window

Master/Detail Form - Error: Cannot Focus a disabled or invisible window

I have a form with master/detail layout. The detailed information is in a
form of dbgrid (3 columns only showing selected information). The form is
being shown modal. When I select an item in a dbgrid and want to click
'edit' btn (to open a form detailing all the data about selected item), I
am getting an error:
Cannot Focus a disabled or invisible window..

The edit btn only puts datasets in dsEdit and shows detailed form.
The detailed form is created automatically by a program, and is also
being shown 'modal'.

Any idea what is wrong with this picture? Does it do with the other form
being created auto (detailed form)? None of the form is disabled by me..

Help!

 

Re:Master/Detail Form - Error: Cannot Focus a disabled or invisible window


Try to disable the autocreate-function for the edit-window.Now you must load
the form manually by the following commands
MyForm := TMyForm.Create(Self);
try
  ShowModal;
finally
  Release;
end;
Now it must work !
PKJR schrieb in Nachricht ...

Quote
>I have a form with master/detail layout. The detailed information is in a
>form of dbgrid (3 columns only showing selected information). The form is
>being shown modal. When I select an item in a dbgrid and want to click
>'edit' btn (to open a form detailing all the data about selected item), I
>am getting an error:
>Cannot Focus a disabled or invisible window..

>The edit btn only puts datasets in dsEdit and shows detailed form.
>The detailed form is created automatically by a program, and is also
>being shown 'modal'.

>Any idea what is wrong with this picture? Does it do with the other form
>being created auto (detailed form)? None of the form is disabled by me..

>Help!

Re:Master/Detail Form - Error: Cannot Focus a disabled or invisible window


Try single stepping through your code in the de{*word*81} to see exactly
which statement triggers the error.  Do you call the SetFocus method
of any component on the new form before you call its Show or ShowModal
method?

Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Re:Master/Detail Form - Error: Cannot Focus a disabled or invisible window


Actually, creating a form dynamically fixed the problem. Still Idon't
knowwhy the other form automatically created by Delphi, could not get a
focus...? How do you set up a focus in a case like this..?

PR

In article <34c76487.2986...@forums.borland.com>,
Bill_T...@compuserve.com.nospam says...

Quote
> Try single stepping through your code in the de{*word*81} to see exactly
> which statement triggers the error.  Do you call the SetFocus method
> of any component on the new form before you call its Show or ShowModal
> method?

> Bill

> (Sorry but TeamB cannot answer support questions received via email.)
> (To send me email for any other reason remove .nospam from my address.)

Re:Master/Detail Form - Error: Cannot Focus a disabled or invisible window


Quote
PKJR wrote:
> Actually, creating a form dynamically fixed the problem. Still Idon't
> knowwhy the other form automatically created by Delphi, could not get
> a
> focus...? How do you set up a focus in a case like this..?

    That error usually happens when you call the setfocus method of some
object BEFORE you make the form visible.
    I usually get that error when I call DBEdit.SetFocus on the
Form.OnCreate event (when the form is invisible and disabled) or
something like that.

    See ya
    Tulius Lima

Re:Master/Detail Form - Error: Cannot Focus a disabled or invisible window


Quote
>focus...? How do you set up a focus in a case like this..?

I do not understand the question? Are you trying to set focus to a
specific component on a form?  If so, call the component's SetFocus
method.

Edit1.SetFocus;
Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Other Threads