Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with FindWindow and browser frames

1 view
Skip to first unread message

Bob Kelly

unread,
May 23, 2001, 4:47:44 AM5/23/01
to
Hi,
does anyone know how to find a window title if it is running inside a
browser frame.
FindWindow can only seem to find the main window not a frame window within
it.


William DePalo [MVP]

unread,
May 24, 2001, 1:10:38 AM5/24/01
to
"Bob Kelly" <b...@dundeecoll.ac.uk> wrote in message
news:e35uNV24AHA.1408@tkmsftngp05...

FindWindow() finds top level windows.

What do you know about the window you seek? If you only know the
title/caption an exhaustive search can be accomplished by enumerating all
the top level windows with EnumWindows() and for each one that you find
enumerating its children with EnumChildWindows().

That is not to say that that is a good method, only that it will work. If
you post some more details someone may offer better advice.

Regards,
Will


Bob Kelly

unread,
May 24, 2001, 5:37:36 AM5/24/01
to
Hi Will,
thanks for your help - let me clarify what I'm trying to do.
I am trying to find the title of a window which is inside a browser frame.
The html code in my example shows the browser window title as FakePage but
has Yahoo running inside it - which as far as I can see is hidden from
findwindow and enumwindows.
Any ideas on how I can see the 'real' window title ?

I'm not up on html but here is the source for the tiny html and a test cpp
program.

//
// save this as page.htm locally.
/*
<HTML>
<HEAD>
<TITLE>FakePage</Title>
</HEAD>
<frameset rows="100%,*" >
<frame src="http://uk.yahoo.com" scrolling="auto">
</frameset>
</HTML>
*/


///////////////////////////////////////////////
// Findpage.cpp
// Try to find the page inside a browser frame
#include <windows.h>
#include <winbase.h>

BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam);
BOOL CALLBACK EnumChildWindowsProc(HWND hwnd,LPARAM lParam);

#define PAGETITLE "Yahoo! UK & Ireland - Microsoft Internet Explorer"
int windowcount=0;

int PASCAL WinMain(HINSTANCE hCurInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HWND w;

MessageBox(NULL,"Try to Find Yahoo window first","USING
FindWindow",MB_OK);

if ( (w=FindWindow(NULL,PAGETITLE)) != NULL)
MessageBox(NULL,PAGETITLE,"Found Window using findwindow - trying
enumwindows",MB_OK);
else
MessageBox(NULL,"Yahoo window not found - trying enumwindows","No
Luck",MB_OK);

EnumWindows(EnumWindowsProc,1L);

MessageBox(NULL,"OK","Finished",MB_OK);
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam )
{
char title[128];
memset(title,0,128);

GetWindowText(hwnd,title,128);

if ( strstr(title,"Yahoo") != NULL )
MessageBox(NULL,title,"Found Window",MB_OK);

EnumChildWindows(hwnd,EnumChildWindowsProc,1L);
return true;
}


BOOL CALLBACK EnumChildWindowsProc(HWND hwnd,LPARAM lParam )
{
char title[128];
memset(title,0,128);

GetWindowText(hwnd,title,128);

if ( strstr(title,"Yahoo") != NULL )
MessageBox(NULL,title,"Found ChildWindow",MB_OK);

return true;
}


"William DePalo [MVP]" <depalow...@compuserve.com> wrote in message
news:ud36frB5AHA.1272@tkmsftngp07...

Bob Kelly

unread,
May 25, 2001, 5:58:48 AM5/25/01
to
Thanks for your help Will,
I will look into your suggestion about code running in the browser, but I really need this to work from a win32 app.
 
Is there any way to get the current url that ie or netscape is focused on by using readprocessmemory ?
 
Regards,
Bob.
"William DePalo [MVP]" <depalow...@compuserve.com> wrote in message news:#uITP2H5AHA.2052@tkmsftngp05...
"Bob Kelly" <b...@zunzeecoll.ac.uk> wrote in message
news:#QhtvVD5AHA.2016@tkmsftngp05...

That should get you started if you own the page that frames the documents.
If you don't you'll have to figure out how to get code to run in the
browser.

 

William DePalo [MVP]

unread,
May 25, 2001, 12:32:11 PM5/25/01
to
"Bob Kelly" <b...@zunzeecoll.ac.uk> wrote in message
news:uizbRGQ5AHA.1172@tkmsftngp05...
<quote>

Is there any way to get the current url that ie or netscape is focused on by
using readprocessmemory ?
</quote>

Sure if you knew the virtual address in the browser where the URL was
stored. :-)

Seriously, if you try to get the data without some level of cooperation from
the browser I don't think your solution will be robust or successful.

An option I didn't mention in my last post is the old SPYGLASS DDE
intreface. It has a "URL echo" function which supposedly sends notifications
about navigation to interested parties. Check out the knowledge base article
Q160957 on the MSDN-CD or at http://msdn.microsoft.com

Regards,
Will


0 new messages