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:Christer Sandberg (chr@gmail.com)
Date:Jun 24, 2009 7:54:01 am
List:net.java.dev.jna.users

Okay, I'll try it. Thanks for your help. I don't know the API that well either. What I'm ultimately is trying to do is to create a NPAPI host in Java simulating a browser to be able to use Firefox/Safar/Chrome plugins such as the Flash plugin.

/Christer

On Wed, Jun 24, 2009 at 4:45 PM, Timothy Wall<twal@dev.java.net> wrote:

You might try turning off w32 direct draw in Java (which is required for the alpha mask image blitting to work, so it might be required for regular drawing as well):

java -Dsun.java2d.noddraw=true ...

I'm not conversant in w32 api drawing, so I couldn't say if your C code is correct.

It might make more sense to blit into an image natively, then let Java use Java2d to put the image into the window.  Depends on what you're ultimately trying to do, though.

On Jun 24, 2009, at 9:01 AM, Christer Sandberg wrote:

Yes!

Perfectly sure. I've printed some debug statements at the native part and in the Java paint(...) part.

So there's nothing special about the code snippets that's wrong?

/Christer

On Wed, Jun 24, 2009 at 2:43 PM, Timothy Wall<twal@dev.java.net> wrote:

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