• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 654
  • Last Modified:

Child window of Java using JNI

Hi All !!!
    I have a requirement, a child window of Java window having a Frame, has to be created in VC++ using JNI.

I create a window which has a Frame, in java and i am calling a JNI function which has been implemented in a DLL using VC++ 6.0. There i need a HWND parameter while creating the child window in VC++. How do i get a handle to the window that is created using java. I am using JDK1.2

For the JNI function i pass the window object which i get as a jobject in VC++.
I am right now API to create a window, but i need to use MFC classes to create a window. How is it possible to typecast a jobject to CWnd * or CMDIFrameWnd * ......

Any suggestions/comments/answers welcome
0
akalmani
Asked:
akalmani
  • 5
  • 4
  • 2
  • +2
1 Solution
 
akalmaniAuthor Commented:
Edited text of question.
0
 
vivexpCommented:
0
 
akalmaniAuthor Commented:
HI vivexp(vivek)
   I have already mentioned what i need i.e the handle of the Java window . This site is ok not much clear.
  Please give me some working code i may give good grades
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
heyhey_Commented:
vivexp:
just a note. PLEASE post COMMENTS, if you don't have working solution.
0
 
nilu011700Commented:
I do not have any workin sol.
I have some suggestion. I was having similar problem of type conversion from Java to C++. The best way I found is to have a wrapper method at Java side which does the conversion to the useful type either at JNI or Java.

Before calling native method;  call the Java method which does type conversion and same for JNI to Java If u need to return some values.

I hope this would help.
Have fun!!
0
 
heyhey_Commented:
Proposed Answer
From: nilu
Date: Tuesday, January 18 2000 - 04:16AM PST

I do not have any workin sol.
I have some suggestion


so why don't you POST COMMENT instead of ANSWER ?
0
 
jini36Commented:
just curious , heyhey R u monitoring this site ???

Enjoy!
0
 
heyhey_Commented:
I just enjoy solving problems :)

when I have suggestion, I post it as comment ...
I haven't posted an ANSWER, before the questioner has solved his problem for more than several months ...

Enjoy ! :)
0
 
akalmaniAuthor Commented:
HI All !!
   Thanks for u r comments but i have already told i want a working code. I am not good in java programming but good in MFC.
  Hope u sent me solution as soon as possible
  HeyHey its a challenge for u. U just tell me how to get the handle of the window may  be through window class present in java or through any API
0
 
vivexpCommented:
Hi,

Since handle to the window is an memory address or pointer to a window. i dont think u can get it in java bcoz java doesnt have pointer concept. probably u can use the object of that window for  interfacing.

Correct me if im wrong!!!!!

try out...
0
 
heyhey_Commented:
http://www.javaworld.com/javaworld/jw-10-1999/jw-10-jni-2.html

GUI and beyond
JNI does have a serious limitation when it comes to extending Java's GUI: there is no standard way for getting native window handles from AWT components. Each VM may implement its AWT differently, and store the window handle in a different place. Future versions of the VM may handle windows in still different ways, ways that cannot be predicted with any certainty right now. With Java 2 platform VMs just starting to get a foothold (without this feature), I don't expect to see a standard way for doing this anytime soon.


you can still cheat - every Window object has associated Text, so you can go through all the available Window objects and search for your Frame's title ... I don't know the Win32 API very well, but should be possible :)

0
 
akalmaniAuthor Commented:
Hi ALL !!
     Thanks for u r help !!! HeyHey.
i know the solution through FindWindow() but this is not the proper solution. I know that JDK1.3 has JAWT where i can get the window handle.
But as i am using JDK1.2 i cannot accept that.
 
 But i will give u points as i have no other solution send me as an answer.

Once again thanks for all and bye
0
 
heyhey_Commented:
Win32 FindWindow is the only possible solution for 1.1 & 1.2 .. I haven't used 1.3 for the moment

btw. you can accept my comment as answer :)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now