Solved

URGENT : windows handle (com.ms.win32)

Posted on 1998-08-06
5
165 Views
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, ...)?

thanks
nishant
0
Comment
Question by:nishant080698
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
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.

0
 

Author Comment

by:nishant080698
ID: 1231550
how do i know what name to use? I have a java class (a.java) that is a stub that in turn calls another java class (b.java) which extends Window (and therefore has no border or title name). also a.java 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?

thanks
nishant
0
 
LVL 16

Expert Comment

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

0
 

Author Comment

by:nishant080698
ID: 1231552
its a window without a border or title bar.
nishant
0
 
LVL 16

Expert Comment

by:imladris
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.

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now