Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get the handle of dialog..

Status
Not open for further replies.

manyvan2000

Programmer
Oct 15, 2003
6
US
hi,
i am developing an application using win32. now i want to get the values in a java based application. i could get the handle to the window using EnumChildWindows(), passing the handle of the desktop window. but i couldnt get the handle of the items in the window like comboboxes, edit controls etc.. the application's base class is SunAwtFrame.

Also, i want to create a thread and leave it as orphan and kill the parent immediately. how to do this?
Mani
 
items in comboboxes/listboxes are not separated windows. All they are a single window which can look like many things, in deppendence of state and/or events.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
hi ion,
how to get the values of the dialog items then?
-Mani
 
HWND theItemWnd = GetDlgItem(hYourDlg, ID_OF_YOUR_ITEM);

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
hi ion,
i think you are not cliear of the problem. i dont know the id of the item since it belongs to another application. the exact scenario is
i have a java based application, which has some controls in it. now, using my application, i need to get the data in the controls of the java application. then i must compare with some text file and then set the values based on it.
for example, the java application is JMyJavaWindow. there are a few controls like JMyEditBox, JMyComboBox,JMyButton etc.. now my windows application will get the values of these and set them to some other values.

in this i could get the window using the EnumChildWindows() and GetWindowText(), then comparing it with the name of the window. but i couldnt proceed because i dont know how to get the values of the controls.
-Mani
 
You do not usualy to work with the HWND from Hava. You can pass any inforation about controls from java to C++ including the items textes. But if you want so much to deal with widow handles, you can do something like this:

//java
public class MyCanvas extends Canvas {

static {
System.loadLibrary("mylib");
}

public native void javaMethod(Graphics g);
}



//C++
#include <jawt_md.h>
#include...
JNIEXPORT void JNICALL javaMethod(JNIEnv* env, jobject canvas, jobject graphics)
{
JAWT awt;
JAWT_DrawingSurface* ds;
JAWT_DrawingSurfaceInfo* dsi;
JAWT_Win32DrawingSurfaceInfo* dsi_win;
jboolean result;
jint lock;
HWND hWnd;

awt.version = JAWT_VERSION_1_3;
result = JAWT_GetAWT(env, &awt);
ds = awt.GetDrawingSurface(env, canvas);
dsi = ds->GetDrawingSurfaceInfo(ds);
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
hWnd = JAWT_Win32DrawingSurfaceInfo->hwnd;

awt.FreeDrawingSurface(ds);
}


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
hi ion,
i think this requires the java code to be changed. i cant change the java code. i only have the application.
thanks and regards
mani
 
hi ion,
is there any other way by which i can access java controls from VC++ other than this. this is very confusing and i dont get it.
for eg.,
java application JAPP has a main screen &quot;Java Main&quot;. in that it has controls edit1, combo1 and button1. now in my win32 application, i give
hWndJava = FindWindow(&quot;SunAwtFrame&quot;,&quot;Java Main&quot;);
now is there any way to do something like
GetItem(hWndJava, edit1);
SetItem(hWndJava, edit1);

what i actually want to do is, when i click on one of the controls of the JAPP, say edit1, i must get the data and the variable associated with the control. then i have to set the data as i need. i cant change any java code. is there anything like GetCtrlUnderMouse or something like this?
thanks and regards
mani
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top