Get file name of a frame

I'm using this code to get a window handle.


GetCursorPos (&pt);
hWnd = WindowFromPoint(pt);


I wish with this code, get a form "file name" of a HTML page.

**************************
Explanation of my problem
**************************

supposing you have three HTML page:

a) index.htm
b) firstframe.htm
c) secondframe.htm

(a) & (b) is two frames opened by "index.htm".

Well, when I click on the "index.htm" window area, if the mouse is clicked
on the area occupied by the "firstframe.htm" the function will display
its file name; for example by using:

GetWindowText(hWnd,lpString,sizeof(lpString));

where "lpString" point to: "firstframe.htm"


I've tried but i get only the file name of the "index.htm"


Thank you
Dario2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SalteCommented:
Your problem is that those frames aren't necessarily separate windows. In particular even if they are it is quite possible that the handle you have isn't the handle to that window. I am not sure what WindowFromPoint() does, if it return the smallest window that contain point or if it return a 'top level window' that contain the point unless the point is within your own application etc...

In any event this is the web browser or html browser's internal implementation that determines how this works and so windows cannot possibly get that right unless the browser has implemented in such a way that windows does happen to get it right.

I am afraid your best bet is to ask the browser of that frame. One thing you CAN do is of course to get the 'index.html' and then from there work your way through, but again that require you to know the internals of the web or html browser you're using.

Some web browsers can respond to external requests and most of them can provide such info to java applet code that runs in the browser. I am afraid that if you are an external application you will have to use whatever interface the browser provide for external programs (for example DOM interface or some such). If you're running a java applet it should be easier but also there it is very much depending on which html browser you're running, internet explorer does it differently from Mozilla for example.

So I am afraid I have to disappoint you, there is no generic way to get the info you seek.

Alf
0
Dario2Author Commented:
My dubt born because I've tried to copy with success only one region of a HTML page, and keep present, a HTML page builded from many frames.

If you try to capture a window handle with my code post below and after you try to create snapshot by clicking on a area of one frame using BitBlt(.....) function, only the clicked area is copied in the destination bitmap container.

This means that every frame in the HTML page, have properly address space and then, I think other informations such as, file name of the frame.
0
SalteCommented:
Not necessarily. This depends on the web browser application. Even if it uses separate windows for each frame those windows doesn't have to have a title and even if they do they don't have to have the tile equal to the name of the file in them. The application determines both the contents of the window and the title and other things.

If the browser have an interface that allow you to get the name of the frame you can use that. For example Internet Explorer has a DOM interface (Document Object Model) that allow you to ask what source file is connected to a specific frame etc. However, this is very much dependent upon the application (Internet explorer in this case). Other web browsers may have a similar interface but it is probably different and it's not obvious they at all have such an interface.

From Java applets however, it is easier in that most browsers do provide ways the applet can ask for the source URL.

However, under no circumstance is this connected with Windows. Windows simply provide a thing called a "window" which can show some graphic on the screen and such windows have a "title" associated with them. What this title contains and how it is related to the contents of the window or if the title contain anything at all is entirely up to the application. There is no policy enforced by windows in this regard - nor should there be, many applications display windows that is NOT originating from a specific file and it would not be meaningful to enforce such a policy at all.

In short, unless you want to be application specific - give it up.

Alf
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bcladdCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to Salte

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.