?
Solved

Get file name of a frame

Posted on 2003-03-24
5
Medium Priority
?
198 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:Dario2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Salte
ID: 8194342
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
 

Author Comment

by:Dario2
ID: 8197494
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
 
LVL 12

Accepted Solution

by:
Salte earned 1000 total points
ID: 8201612
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
 
LVL 11

Expert Comment

by:bcladd
ID: 9558626
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question