Board index » delphi » Problem with focus changes between re-parented child forms

Problem with focus changes between re-parented child forms

I've uploaded a test project to borland.public.attachments which
illustrates my problem. It is only 11Kb zipped and not much more than
that unzipped. I invite anyone who is willing to take a look to try it
out. Here is what I'm facing:

This test project illustrates a problem I've been having with child
windows responding correctly to focus changes. The project simulates
MDI via SDI forms. The main form is descended from TfrmSDIParent and
the two child forms are descended from TfrmSDIChild.

The TfrmSDIParent has code to maintain the Windows menu, listing all
child forms.

There are two menu choices for creating instances of two child forms.
Once these are created you can change focus between them by clikcing
anywhere on the child forms. This is normal behavior.

The problem I am facing is that when you click on the non-active child
form in one of its controls, the focus does not change as it should.
The focus only changes if you click somewhere on the form background
or caption bar.

I need to figure out why and how to fix it!

Doug Chamberlin
DChamber...@ne.mediaone.net

 

Re:Problem with focus changes between re-parented child forms


Test it.

procedure TfrmSDIChild.WndProc(var pMsg: TMessage);
if    (pMsg.Msg = WM_MOUSEACTIVATE) or
                        (pMsg.Msg = WM_CREATE) or
   (pMsg.Msg = WM_LBUTTONDOWN) or
   (pMsg.Msg = WM_RBUTTONDOWN) or
   (pMsg.Msg = WM_NCLBUTTONDOWN) or
   (pMsg.Msg = WM_NCRBUTTONDOWN) then begin
  ActivateForm;
  end;//if
 // Always call for the normal processing.
 inherited WndProc(pMsg);
end;

************************************
Boyan Iliev

Home pages:
http://members.xoom.com/bobbysoft
http://www.geocities.com/bobbysoft_us/

My Delphi components:
http://bobbysoft.virtualave.net
************************************

Quote
Doug Chamberlin <dchamber...@dlawton.com> wrote in message

news:2377fso39a9dh4qu8i5deiqpfcq6jh9fk4@4ax.com...
Quote
> I've uploaded a test project to borland.public.attachments which
> illustrates my problem. It is only 11Kb zipped and not much more than
> that unzipped. I invite anyone who is willing to take a look to try it
> out. Here is what I'm facing:

> This test project illustrates a problem I've been having with child
> windows responding correctly to focus changes. The project simulates
> MDI via SDI forms. The main form is descended from TfrmSDIParent and
> the two child forms are descended from TfrmSDIChild.

> The TfrmSDIParent has code to maintain the Windows menu, listing all
> child forms.

> There are two menu choices for creating instances of two child forms.
> Once these are created you can change focus between them by clikcing
> anywhere on the child forms. This is normal behavior.

> The problem I am facing is that when you click on the non-active child
> form in one of its controls, the focus does not change as it should.
> The focus only changes if you click somewhere on the form background
> or caption bar.

> I need to figure out why and how to fix it!

> Doug Chamberlin
> DChamber...@ne.mediaone.net

Other Threads