Board index » delphi » Mdi child looses focus

Mdi child looses focus

Howdie!

I have an Mdi application with a child window containing an editor (and a
list). When I switch between Mdi children, I manage to give the focus to the
editor child in the Mdi child. However, when I switch between applications,
the focus of the editor is lost.

I catch WM_ActivateApp in the main window, and i successfully identifies the
top Mdi child, but I fail to give focus to the editor.

I use this in the Mdi child window procedure:

    WM_MdiActivate:
      If LParam=Mdi Then Begin        { if activated }
        Proj:=GetProject(Mdi);        { get object for Mdi child }
        SetFocus(Proj^.Edit);        { sets focus to the editor child }
      End;

I have this in the window procedure of the main window:

    WM_ActivateApp:
      If WParam<>0 Then Begin        { if activated }
        If GetTopProject(Proj) Then Begin    { get object for Mdi child }
          WriteLn('Focus');        { to show that we really get here }
          SetFocus(Proj^.Edit);        { has no effect }
        End;
      End;

Why does this not work?

/GreenGhost
---
http://hem.passagen.se/guffa/en
---
kill the spammer to mail me

 

Re:Mdi child looses focus


I have no idea if this is the problem but try to use SetFocus on the
component, like in Edit1.SetFocus;

On Wed, 2 Feb 2000 15:57:52 +0100, in the misty caves of
comp.lang.pascal.delphi.misc, I heard "G?ran Andersson"
<gu...@iname.spammer.com> telling this scary story:

Quote
>Howdie!

>I have an Mdi application with a child window containing an editor (and a
>list). When I switch between Mdi children, I manage to give the focus to the
>editor child in the Mdi child. However, when I switch between applications,
>the focus of the editor is lost.

>I catch WM_ActivateApp in the main window, and i successfully identifies the
>top Mdi child, but I fail to give focus to the editor.

>I use this in the Mdi child window procedure:

>    WM_MdiActivate:
>      If LParam=Mdi Then Begin        { if activated }
>        Proj:=GetProject(Mdi);        { get object for Mdi child }
>        SetFocus(Proj^.Edit);        { sets focus to the editor child }
>      End;

>I have this in the window procedure of the main window:

>    WM_ActivateApp:
>      If WParam<>0 Then Begin        { if activated }
>        If GetTopProject(Proj) Then Begin    { get object for Mdi child }
>          WriteLn('Focus');        { to show that we really get here }
>          SetFocus(Proj^.Edit);        { has no effect }
>        End;
>      End;

>Why does this not work?

>/GreenGhost
>---
>http://hem.passagen.se/guffa/en
>---
>kill the spammer to mail me

-------------
Bart Schouten
-------------
StarCraft, Delphi & Java.

Re:Mdi child looses focus


Thanks for the suggestion, but I don't use components.
(Actually I don't use Delphi either, but there is no Free Pascal NG (yet).)

Edit is of the type HWnd, a window handle. The window is an editor control.

/GreenGhost

Bart Schouten skrev i meddelandet <38985c64.616...@news.hccnet.nl>...

Quote

>I have no idea if this is the problem but try to use SetFocus on the
>component, like in Edit1.SetFocus;

>On Wed, 2 Feb 2000 15:57:52 +0100, in the misty caves of
>comp.lang.pascal.delphi.misc, I heard "G?ran Andersson"
><gu...@iname.spammer.com> telling this scary story:

>>Howdie!

>>I have an Mdi application with a child window containing an editor (and a
>>list). When I switch between Mdi children, I manage to give the focus to
the
>>editor child in the Mdi child. However, when I switch between
applications,
>>the focus of the editor is lost.

>>I catch WM_ActivateApp in the main window, and i successfully identifies
the
>>top Mdi child, but I fail to give focus to the editor.

>>I use this in the Mdi child window procedure:

>>    WM_MdiActivate:
>>      If LParam=Mdi Then Begin        { if activated }
>>        Proj:=GetProject(Mdi);        { get object for Mdi child }
>>        SetFocus(Proj^.Edit);        { sets focus to the editor child }
>>      End;

>>I have this in the window procedure of the main window:

>>    WM_ActivateApp:
>>      If WParam<>0 Then Begin        { if activated }
>>        If GetTopProject(Proj) Then Begin    { get object for Mdi child }
>>          WriteLn('Focus');        { to show that we really get here }
>>          SetFocus(Proj^.Edit);        { has no effect }
>>        End;
>>      End;

>>Why does this not work?

>>/GreenGhost
>>---
>>http://hem.passagen.se/guffa/en
>>---
>>kill the spammer to mail me

>-------------
>Bart Schouten
>-------------
>StarCraft, Delphi & Java.

Re:Mdi child looses focus


On Fri, 4 Feb 2000 08:58:00 +0100, in the misty caves of
comp.lang.pascal.delphi.misc, I heard "G?ran Andersson"
<gu...@iname.spammer.com> telling this scary story:
Quote
>Thanks for the suggestion, but I don't use components.
>(Actually I don't use Delphi either, but there is no Free Pascal NG (yet).)

So you're using freepascal? Well, at the moment I'm studying a Win32
API book, but for now I can't help you

Quote
>Edit is of the type HWnd, a window handle. The window is an editor control.

>/GreenGhost

>Bart Schouten skrev i meddelandet <38985c64.616...@news.hccnet.nl>...

>>I have no idea if this is the problem but try to use SetFocus on the
>>component, like in Edit1.SetFocus;

>>On Wed, 2 Feb 2000 15:57:52 +0100, in the misty caves of
>>comp.lang.pascal.delphi.misc, I heard "G?ran Andersson"
>><gu...@iname.spammer.com> telling this scary story:

>>>Howdie!

>>>I have an Mdi application with a child window containing an editor (and a
>>>list). When I switch between Mdi children, I manage to give the focus to
>the
>>>editor child in the Mdi child. However, when I switch between
>applications,
>>>the focus of the editor is lost.

>>>I catch WM_ActivateApp in the main window, and i successfully identifies
>the
>>>top Mdi child, but I fail to give focus to the editor.

>>>I use this in the Mdi child window procedure:

>>>    WM_MdiActivate:
>>>      If LParam=Mdi Then Begin        { if activated }
>>>        Proj:=GetProject(Mdi);        { get object for Mdi child }
>>>        SetFocus(Proj^.Edit);        { sets focus to the editor child }
>>>      End;

>>>I have this in the window procedure of the main window:

>>>    WM_ActivateApp:
>>>      If WParam<>0 Then Begin        { if activated }
>>>        If GetTopProject(Proj) Then Begin    { get object for Mdi child }
>>>          WriteLn('Focus');        { to show that we really get here }
>>>          SetFocus(Proj^.Edit);        { has no effect }
>>>        End;
>>>      End;

>>>Why does this not work?

>>>/GreenGhost
>>>---
>>>http://hem.passagen.se/guffa/en
>>>---
>>>kill the spammer to mail me

>>-------------
>>Bart Schouten
>>-------------
>>StarCraft, Delphi & Java.

-------------
Bart Schouten
-------------
StarCraft, Delphi & Java.

Other Threads