Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep a child window on top? 1

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
I have an issue. When i click an incon in a toolbar, my child window is not active anymore and when i try to do something it will tell me that it cannot do that on a non focus or hidden window.
How can i keep my child window active regarding of anything?
Thanks.
 
Show us the code that your button is trying to execute.
 
By "child window" do you mean you are writing an MDI application or a regular SDI?
 
The code is too much to write...I just know that when I activate a panel, I loose control of the MDI child window.
I tried to use child.setfocus;
Child been the activechild but that is not working.
Thanks.
 
When you visit the doctor you can't just say "my foot hurts, call me when you know what's wrong" and leave without showing him your foot.

Chop out everything you can so that the problem still persists, and show us what you can. Along the way you just might solve the problem yourself.

Make sure that when you create the children you set the aOwner to the Application:
Code:
child := tMDIChild.create( Application );

Focus children with:
Code:
child.BringToFront;

Access the children by counting through MDIChildren:
Code:
//----------------------------------------------------------------------------
// FindMDIChild
//----------------------------------------------------------------------------
// function
//   Find a specific child given its caption.
//
// returns
//   The child, or nil if not found.
//
function tMainForm.FindMDIChild( caption: string ): tMDIChild;
  var i: integer;
  begin
  result := nil;
  for i := MDIChildCount-1 downto 0 do
    if MDIChildren[ i ].caption = caption
      then begin
           result := tMDIChild( MDIChildren[ i ] );
           break
           end
  end;

Access the currently-active child with:
Code:
with activeMDIChild as tMDIChild do ...

Make sure you are doing things in this order and not some other way. If this still doesn't help, chop out everything that you can so that the application still exhibits the odd behavior and post what you find.

Hope this helps.
 
Thanks....You gave me the command I needed. i also did find out that the problem came from a popup menu.
Sincerely,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top