Hi, Using nsIWindowWatcher I'm able to get the active browser window. From that I can get the child nsIDOMWindows that represent the Web page(s) (tab windows) that are open in the browser. The problem I have is how do I determine which of the web pages is the active page. So in other words how can I determine which of the nsIDOMWindows represents the active window? i.e. the top-most web page in the browser, the one someone using the browser is reading. I've included some sample code from how I'm doing this below. This code works fine _EXCEPT_ that it's missing the bit to determine which of the web page windows is the active window. Thanks, Damien
void MyMozilla::TimerCallback(nsITimer *aTimer, void *aClosure)
{
OutputDebugString(_T("In the timer...\n"));
nsCOMPtr<nsIWindowWatcher>
wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsIDOMWindow *wind = NULL;
wwatch->GetActiveWindow(&wind);
if (wind)
{
PRUint32 nNumberOfWindows = 0;
nsIDOMWindowCollection *windCollection = NULL;
wind->GetFrames(&windCollection);
windCollection->GetLength(&nNumberOfWindows);
for (int nCnt=0;nCnt<nNumberOfWindows;nCnt++)
{
nsIDOMWindow *wind2 = NULL;
windCollection->Item(nCnt, &wind2);
nsIDOMDocument *dom_doc = NULL;
wind2->GetDocument(&dom_doc);
if (dom_doc)
{
nsCOMPtr<nsIDOMHTMLDocument>
htmlDomDocument(do_QueryInterface(dom_doc));
if (htmlDomDocument)
{
OutputDebugString(_T("Gotcha!!!...\n"));
nsEmbedString strTitleText;
htmlDomDocument->GetTitle (strTitleText);
const PRUnichar *strTitle =
strTitleText.get();
nsEmbedString strURLText;
htmlDomDocument->GetURL(strURLText);
const PRUnichar *strURL = strURLText.get();
}
}
}
}
}
<<attachment: winmail.dat>>
