6 messages in net.java.dev.jna.usersRe: [jna-users] Simple JNA question.
FromSent OnAttachments
Christer SandbergJun 24, 2009 5:06 am 
Timothy WallJun 24, 2009 5:43 am 
Christer SandbergJun 24, 2009 6:00 am 
Timothy WallJun 24, 2009 7:45 am 
Christer SandbergJun 24, 2009 7:54 am 
Christer SandbergJun 25, 2009 12:57 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Simple JNA question.Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Jun 24, 2009 5:43:07 am
List:net.java.dev.jna.users

Are you certain your "paint" method is being called?

If so, try the most simple drawing operation first (like a fill or a line).

On Jun 24, 2009, at 8:07 AM, Christer Sandberg wrote:

Hi!

I've been trying to do a simple thing. Say that I have a java.awt.Canvas instance that I want some native code to draw on. The native code (i.e. method) in a DLL could look something like this:

void simpleDraw(HWND hwnd) { PAINTSTRUCT ps; HDC hdc; RECT rc;

hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); FrameRect(hdc, &rc, GetStockBrush(BLACK_BRUSH)); DrawText(hdc, L"This is a simple draw...", 24, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hwnd, &ps); }

The way I call it is to extends a Canvas paint method and invoke this as:

public void paint(Graphics g) { lib.simpleDraw(Native.getComponentPointer(this)); }

The problem that I'm having is that nothing get's drawn on the canvas. How should I do this simple thing. I must be missing something!?

Thanks in advance, Christer