SetWindowLongPtr vs SetWindowLong (x64 vs x86)

602 views
Skip to first unread message

Lennart P.

unread,
Dec 22, 2016, 7:19:09 PM12/22/16
to Java Native Access
Hello,

Previously I have been using SetWindowLongPtr to change the owner of the window, and it works fine. However, I recently had to move everything to 32bit since I had to use 32bit DLLs. After switching to 32bit JVM the SetWindowLongPtr fails with error: "java.lang.UnsatisfiedLinkError: Error looking up function 'SetWindowLongPtr': The specified procedure could not be found.", which is kind of understandable. From MSDN: "When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function." So I should just use SetWindowLong function instead.

Now to the actual problem... If I could previously do 
SetWindowLongPtr(childHwnd, WinUser.GWL_HWNDPARENT, parentHwnd.getPointer());

Then what would the equivalent line be for SetWindowLong function?
SetWindowLong(childHwnd, WinUser.GWL_HWNDPARENT, ???)

The 3rd parameter has to be Integer?! It should be so simple, yet I am clueless.

Kind regards,
Lennart

Timothy Wall

unread,
Dec 24, 2016, 9:51:15 AM12/24/16
to jna-...@googlegroups.com
You can use `Pointer.nativeValue()` and cast it to the appropriate size (or define an additional method mapping which takes a Pointer as an argument), e.g.

    // DO NOT use this mapping on 64-bit!
    SetWindowLong(HWND hWnd, int nIndex, Pointer dwPointerValue);

--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lennart P.

unread,
Dec 24, 2016, 11:06:14 AM12/24/16
to Java Native Access
Super. Thanks very much!
Reply all
Reply to author
Forward
0 new messages