How can i get the Handle (HWND) of a java.awt.Canvas on Windows NT/98?

Davanum Srinivas

import java.awt.*;
import sun.awt.*;

/* This class uses undocumented features of Sun's JDK  */
/* Works only on Windows NT/98 with JDK1.1.8, JDK1.2.2 */
public class SunCanvas extends Canvas
{
    /* Returns the HWND for canvas. */
    public int getHWND() 
    {
        DrawingSurfaceInfo drawingSurfaceInfo;
        Win32DrawingSurface win32DrawingSurface;
        int hwnd = 0;
     
        /* Get the drawing surface */   
        drawingSurfaceInfo =
            ((DrawingSurface)(getPeer())).getDrawingSurfaceInfo();
        
        if (null != drawingSurfaceInfo) {
            drawingSurfaceInfo.lock();
            /* Get the Win32 specific information */
            win32DrawingSurface = 
                 (Win32DrawingSurface)drawingSurfaceInfo.getSurface();
            hwnd = win32DrawingSurface.getHWnd();
            drawingSurfaceInfo.unlock();
        }
        return hwnd;
    }
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact