Results 1 to 6 of 6
  1. #1
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    Default JNI: Why this code not working?

    Purpose: Moving the from...( means same thing what happens when you click on Titlebar and start dragging.)


    in Java
    ========
    Java Code:
    private native void moveIt(int Handle);
    public BasicTest()
    {
            ........
            .........
            addMouseListener(new MouseAdapter()
            {
            	public void mousePressed(MouseEvent e)
            	{
            		if(e.getButton() == MouseEvent.BUTTON1)
            		moveIt(HWND);
            	}
            	
            });
            
            setLocationRelativeTo(null);
    }
    In Dll:
    ======
    Java Code:
    /*
     * Class:     BasicTest
     * Method:    moveIt
     * Signature: (I)V
     */
    JNIEXPORT void JNICALL Java_BasicTest_moveIt
      (JNIEnv *env, jobject obj, jint handle)
    {
    	ReleaseCapture();
    	SendMessage((HWND)handle, WM_NCLBUTTONDOWN, HTCAPTION, NULL);
    	//SetWindowText((HWND)handle, "OK"); // test to see if HWND is right
    }
    whats wrong here? why this code doesn't move the window(frame)?:confused:

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Question rabbit hunting from 35,000 feet

    Trying to get-going on JNI myself, but the HWND in the Java method call is not Java. I would not expect a window handle data type to be avilable in Java, something like rabbit hunting from 35,000 feet ( lame, yes - it's early am )

    I don't see where we are going to manipulate windows behind the Java API if Java is the one to create the window.
    Last edited by Nicholas Jordan; 11-23-2008 at 02:25 AM.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    Default

    Quote Originally Posted by Nicholas Jordan View Post
    Trying to get-going on JNI myself, but the HWND in the Java method call is not Java. I would not expect a window handle data type to be avilable in Java.
    Hi thanks for responding... :)

    well, HWND is declared as :
    int HWND; in java...

    another native funct. "int getWindowHandle(...)" set it to the value(window handle) when the window(frame) is visible first time.

    The handle is correct. ( I sent other simple messages like "SetWindowTitle(..)" etc. and it responded.).

    I have no idea why WM_NCL... is not working... (so I posted here..), my best guess is CAPTURECHANGED is failing but why:confused: I don't know.

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Well set title is textual, setWindowPosition((HWND) int) is - among other things - probably a cast to void or something, gets rather bulky digging through all the headers. Where's the header for WM_NCL?
    Java Code:
    C:\dm\include\WIN32\WINDOWS.H
    I will read it and see what I can come up with.

    For the moment, change HWND to a beginner-readable variable name in the Java code as respect for Masters so we to have to listen to it and can focus on the problem at hand.

    While you are at it, maybe you can read up on Boyer-Moore, Hoorspool, Raita from Johann Burkhard, I need to swamp massive stores and need the power...
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  5. #5
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    Default

    hello,

    WM_NCLBUTTONDOWN is defined in "winuser.h"

    BTW I crated a demo app, take a look at it ....

    The attached zip has following contents:

    1)TestApp.jar
    2)TestDll.dl
    and
    3)src.zip - contains source code for both Java & native dll.
    Attached Files Attached Files

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default looks correct to me.

    dll code checks for 0:
    Java Code:
    JNIEXPORT jint JNICALL Java_TestApp_nGetWinHandle
      (JNIEnv *env, jobject obj, jstring title)
    and the other calls are working, so maybe we will luck out and have a master join the post....
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Similar Threads

  1. I am working on java!
    By pawankumarom in forum New To Java
    Replies: 33
    Last Post: 03-06-2009, 11:24 AM
  2. My code is not working properly ..modify it
    By Shyam Singh in forum New To Java
    Replies: 14
    Last Post: 07-16-2008, 05:48 PM
  3. Replies: 8
    Last Post: 05-28-2008, 07:00 AM
  4. Working With ANT
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 08:16 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •