URGENT : windows handle (

Posted on 1998-08-06
Last Modified: 2010-04-16
I have a java application that extends java.awt.Window.  How can I get the Win32 handle (as an int) to this window within my code, which I can then pass to functions like User32.SetWindowPos(int hWnd, ...)?

Question by:nishant080698
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
  • 3
  • 2
LVL 16

Accepted Solution

imladris earned 50 total points
ID: 1231549
This is actually more of a pointing you in the right direction than a specific answer. It involves some windows programming, a topic in which I am ignorant on the the details. But since noone else has proffered anything concrete, here's what I have.

We ran into a similar situation. We needed to get the handle of a Java program. The solution we came up with was to use the name. A native windows routine would scan the list of running applications, find the one of interest, by name, and acquire the handle from there. In our case it was used directly in the native routine, however, it could undoubtedly be passed back into the Java program just as well.


Author Comment

ID: 1231550
how do i know what name to use? I have a java class ( that is a stub that in turn calls another java class ( which extends Window (and therefore has no border or title name). also is registered as an activeX object A.Java.1 , and i am creating the object in VB using this classname. so, how can i then refer to it by name? i assume you were referring to using
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
                    ByVal lpWindowName As Long) As Long

what value do i pass to lpClassName and lpWindowName respectively?

LVL 16

Expert Comment

ID: 1231551
Use whatever name that winds up in the title bar.


Author Comment

ID: 1231552
its a window without a border or title bar.
LVL 16

Expert Comment

ID: 1231553
OK, whatever title would have been there, if there had been a title bar.

Specifically, in the case of straight Java, there is a constructor for Frame that takes a String as an argument. This string will appear as the title (if you have a title bar). This is how we specified the name of the program.


Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JAVA API design with micro service cloud in mind 1 113
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 71
Bot application - advice 3 81
Firefox and firebub 5 28
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

738 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