title: Get foreground CHILD window
body: <p>Whenever Skype is in <strong>Default View</strong>, the <code>TConversationWindow</code>'s become children of the <code>tSkMainForm</code> Window.</p>
  
  <p>I am having problems finding out which <code>TConversationWindow</code> is active - however it's not like an MDI interface - only <strong>one</strong> <code>TConversationWindow</code> is visible, like if it was a <strong>Tab/Page</strong>.</p>
  
  <p>When I do <code>GetForegroundWindow</code>, Skype's MainForm handle is returned (<code>tSkMainForm</code>). Is there any way that I can get the foreground <code>TConversationWindow</code> within Skype?</p>
  
  <p><a href="https://stackoverflow.com/questions/6541629/detecting-whether-skype-is-in-compact-view-or-default-view">This question</a> of mine has screenshots of Skype's Default View, if you need it. :)</p>
  
  <p><strong>EDIT</strong>: Here is a screenshot of the Winspector Hierachy:</p>
  
  <p><img src="https://i.stack.imgur.com/rjo1H.png" alt="enter image description here"></p>
  
  <p><strong>EDIT2</strong>: I tried going thru the windows like this:</p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
    function GetClassName(Handle: HWND): String;
    var
    Buffer: array[0..MAX_PATH] of Char;
    begin
    Windows.GetClassName(Handle, @Buffer, MAX_PATH);
    Result := String(Buffer);
    end;
  Var
   Wnd: HWND;
   SkypeWnd: HWND;
  begin
   SkypeWnd := FindWindow('tSkMainForm',nil);
  
   Wnd := GetTopWindow(SkypeWnd);
  
   while (GetClassName(Wnd) &lt;&gt; 'TConversationForm') and (Wnd &lt;&gt; 0) and (not IsWindowVisible(Wnd)) do
   begin
     Wnd := GetNextWindow(Wnd,GW_HWNDNEXT);
   end;
  
   Label1.Caption := GetClassName(Wnd)+' - '+GetHandleText(wnd);
  
  end;
  </code></pre>
  
  <p>The above is supposed to find the visible window, however when I debug it, it never enters the Begin End within the While loop, and Label1 displays "TChromeMenu - ChromeToolbar". When I remove the IsWindowVisible check, it atleast finds a TConversationForm. What am I doing wrong?</p>
  
  <p><strong>EDIT3</strong>: By placing the IsWindowVisible and getClassName check inside the loop, and break when true, I managed to do it. :)</p>