[Java] HWND van Canvas halen [jdk1.4]

Pagina: 1
Acties:

  • Nexopheus
  • Registratie: Juni 2001
  • Laatst online: 28-01 13:50
Iemand een idee hoe ik de HWND van een canvas kan krijgen?
De mogelijkheid zoals deze in jdk1.3 was bestaat niet meer in jdk1.4/

Een oplossing die ik liever niet gebruik ivm de tijd is het schrijven een jni lib. voor de canvas.
Java:
1
2
3
public class nativeCanvas extends java.awt.Canvas{
     public int native getHWND(Canvas c);
}


Ideën?

Wat niet kan is nog nooit gebeurd


  • .oisyn
  • Registratie: September 2000
  • Laatst online: 21:34

.oisyn

Moderator Devschuur®

Demotivational Speaker

waarom gebruik je liever geen JNI?

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.


  • Nexopheus
  • Registratie: Juni 2001
  • Laatst online: 28-01 13:50
Tja, ben eingelijk op zoek naar een kant-en-klaar-ik-ben-te-lui oplossing. :)

Wellicht dat de jni oplossing toch het beste is. (Zoals ik het nu zie, zelfs de enige oplossing)

Uit jawt.h\
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
In Win32, a programmer wishes to access the HWND of a canvas to perform
 * native rendering into it.  The programmer has declared the paint() method
 * for their canvas subclass to be native:
 *
 *
 * MyCanvas.java:
 *
 * import java.awt.*;
 *
 * public class MyCanvas extends Canvas {
 *
 *     static {
 *         System.loadLibrary("mylib");
 *     }
 *
 *     public native void paint(Graphics g);
 * }
 *
 *
 * myfile.c:
 *
 * #include "jawt_md.h"
 * #include <assert.h>
 *
 * JNIEXPORT void JNICALL
 * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
 * {
 *     JAWT awt;
 *     JAWT_DrawingSurface* ds;
 *     JAWT_DrawingSurfaceInfo* dsi;
 *     JAWT_Win32DrawingSurfaceInfo* dsi_win;
 *     jboolean result;
 *     jint lock;
 *
 *     // Get the AWT
 *     awt.version = JAWT_VERSION_1_3;
 *     result = JAWT_GetAWT(env, &awt);
 *     assert(result != JNI_FALSE);
 *
 *     // Get the drawing surface
 *     ds = awt.GetDrawingSurface(env, canvas);
 *     assert(ds != NULL);
 *
 *     // Lock the drawing surface
 *     lock = ds->Lock(ds);
 *     assert((lock & JAWT_LOCK_ERROR) == 0);
 *
 *     // Get the drawing surface info
 *     dsi = ds->GetDrawingSurfaceInfo(ds);
 *
 *     // Get the platform-specific drawing info
 *     dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
 *
 *     //////////////////////////////
 *     // !!! DO PAINTING HERE !!! //
 *     //////////////////////////////
 *
 *     // Free the drawing surface info
 *     ds->FreeDrawingSurfaceInfo(dsi);
 *
 *     // Unlock the drawing surface
 *     ds->Unlock(ds);
 *
 *     // Free the drawing surface
 *     awt.FreeDrawingSurface(ds);
 * }
 *
 */


Moet hier dan maar even mee stoeien!

[ Voor 84% gewijzigd door Nexopheus op 18-02-2003 17:44 ]

Wat niet kan is nog nooit gebeurd


  • Nexopheus
  • Registratie: Juni 2001
  • Laatst online: 28-01 13:50
UPDATE:
De tool die ik aanhaalde (Bridge2Java) heeft een eigen Object waarmee je de hwnd kunt ophalen.
Opgelost dus.

Wat niet kan is nog nooit gebeurd