Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Got stucked with a jna native application  RSS feed

 
Tamas Horvath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear users,
I have a program that starts up a notepad, and I want it to be contained inside a java application.
Like: http://www.codeproject.com/KB/threads/applicationhost.aspx
Everything runs fine, but finally the SetParent does not work at all, but it return a pointer (showing me that it is success)
The SetParent() does not set the parent, but everything seems to be fine.

The windows supports the following functions to handle windows:
http://msdn.microsoft.com/en-us/library/ff468919%28v=VS.85%29.aspx

The following is done:
CreateProcessA() called to start notepad (and I used it because java does not allow me to retrieve process id).
WaitForInputIdle() used to wait for the window to become visible, and to retrieve its handle.
GetTopWindow(null), GetWindowThreadProcessId(w, pid), GetWindow(w, 2); is used to find the window of the given process id. (If I close the notepad before these are executed the system does not find a window for that process id, so it works as well)
Finally the SetParent() is used to set the parent
From the microsoft msdn:
"If the function succeeds, the return value is a handle to the previous parent window."
And it does return a pointer!
Result:
The notepad window does not hosted

Here are the files I use:



---------------------------------------------------



----------------------------------------------------


Thnx,
Tamas
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!