HWND Reference

Hi,

Back on the JDK 1.3 days you could grab a HWND reference in Windows to display a Internet Explorer window within your java GUI, using the following (along with other native methods):


public int getHWND() {
        DrawingSurfaceInfo drawingSurfaceInfo;
        Win32DrawingSurface win32DrawingSurface;
        int hwnd = 0;
        
        drawingSurfaceInfo =
                ((DrawingSurface)(getPeer())).getDrawingSurfaceInfo();
        
        if (null != drawingSurfaceInfo) {
            drawingSurfaceInfo.lock();
    
            win32DrawingSurface =
                    (Win32DrawingSurface)drawingSurfaceInfo.getSurface();
            hwnd = win32DrawingSurface.getHWnd();
            drawingSurfaceInfo.unlock();
        }
        return hwnd;
    }

Now, as of the JDK 1.5, classes such as the DrawingSurfaceInfo and Win32DrawingSurface no longer exist. Does anyone know of an approach that would replace the above code? By the way, the code is not mine, and I’m trying to achieve what is described here: http://www.codeproject.com/java/javacom.asp

I need to open a Internet Explorer window within a Java GUI, with all activeX controls enabled. I cannot simply call IE to start outside the application, it HAS to be within a JPanel… =/

How about using the JDIC Web Browser : supports IE, Mozilla, and runs on windows, linux (and sometimes mac os)

Lilian :slight_smile:

I need to write a small swing app that does a few things; one of them is opening a JPanel that will show IE content, generated via an ActiveX control that listens to a streaming server.

Writting the communicating middleware for the video stream in Java itself would be a pain, and not guaranteed to work at all, not to mention that it would also be very time consuming. The client’s requirement specifies that the application should work on windows (no portability required), but I want to write this in Java because it will allow me for better integration with the Java EE application running on the server, in the near future (reason why I’m not doing this on C++ or C#).

So, can I open a HWND window and start IE on it, using the latest JDK? I bet I have to go JNI… I’m also looking at JNative, as of now.

Thanks for any insight :smiley:

Look at the french web site on my sig : image thumbnails are uploaded snapshots of IE or Mozilla windows, driven by a small Swing application listening to web server requests…

The application itself is a set of classes (around 10 Kb) + jdic jars (around 100Kb) + jdic.dll (another 100 Kb)

Less than 250 Kb, and extremely easy to develop with the browser event model.

if it’s too heavy for your use case, or just not the right solution, may be you could browse the JDIC project and see how it does IE embedding ?
Sorry I can’t help more here on the JNI side…

Lilian :slight_smile:

Now I see what you meant before! Sorry for the misunderstanding! I bet this will help me a lot :wink:
Thank you very much!

You can access this information from JNI using the jawt stuff (jawt.h and jawt_md.h). Check the JNI documentation for more info.

Yes, indeed.

JDIC will be helpful to display browser content on a window, which is also one of the requirements. For the actual ActiveX control, I’ll have to use ATL in C++, and access the whole mess with JNI, using the libraries you’ve just mentioned =D

Thanks for the help, fellows!

If you look in rt.jar in the jre/lib directory, you can see what undocumented sun classes are available. However as they always say, you can rely on these being available from versino to version.

You surely meant “you can’t rely on them”, right? :stuck_out_tongue: Writing JNI code seems to be a safer bet.

JDIC was useful to start an IE session within a Java container, shooting one of the requirements down ;D. Now I need to write a C++ wrapper class that uses ATL and COM to manage an ActiveX control, and call its methods. The control itself is a visual component, so it will be painted on a Canvas, instantiated and initialized via JAWT and native methods on the Java side.

Wish me luck… for all the tutorials I’ve found that deal with ATL are deeply tied to an IDE (argh, Visual Studio). They all start like this… “Create a New ATL Project by clicking somewhere…”. What’s wrong with .NET developers, don’t they like to know about their code without an IDE’s interference? ;D

Note: I was joking. IDEs are good, not evil. But I hate tutorials that do not teach you the concepts, but the tool usage instead :wink: