Docking a java application jna on windows -


I am trying to create a windows dockable application that prevents a part of the screen from showing in that place is .

I have tried to use JNI and JNA. The above code shows how far I got.

  package jnadock; Import com.sun.jna.Library; Import com.sun.jna.Native; Import com.sun.jna.Pointer; Import com.sun.jna.platform.win32.SheELPAPI; Import com.sun.jna.platform.win32.SheELPAP.APPBARDATA; Import com.sun.jna.platform.win32.WinDef.DWORD; Import com.sun.jna.platform.win32.WinDef.HWND; Import com.sun.jna.platform.win32.WinDef.UINT_PTR; Import com.sun.jna.platform.win32.WinUser; Import com.sun.jna.win32.StdCallLibrary; Import com.sun.jna.win32.W32APIFunctionMapper; Import com.sun.jna.win32.W32APITypeMapper; Import java.util.HashMap; Import java.util.Map; Import javax.swing.JFrame; Public Sector Jndok {Personal HWND HW Global; Private final string framing = "dockable frame"; Public Interface Shell32 StdCallLibrary {Final static map & lt; String, Object & gt; WIN32API_OPTIONS = New Hashmap & lt; String, Object & gt; () {Private Static Last Long Serial VERSIONUID = 1L; {Put (library.OPTION_FUNCTION_MAPPER, W32APIFUNCTIONMapper.UNICODE); Put (library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); }}; Public Shell32 INSTANCE = (Shell32) Native.loadLibrary ("Shell32", Shell32.class, WIN32API_OPTIONS); UINT_PTR SHAppBarMessage (DWORD dwMessage, Epidata Peeda); } Public Interface User32 StdCallLibrary (last static map & lt; string, object & gt; WIN32API_OPTIONS = new hashmap & lt; string, object & gt; () {personal fixed last long serial VERSIONUID = 1L; {put (library.OPTION_FUNCTION_MAPPER, W32APIFUNCTIONMapper.UNICODE); (Library OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);}}; User32 INSTANCE = (User 32) .Native.load Library ("User 32", User 32.class, WIN32API_OPTIONS); Boolean EnumWindows (WinUser.WNDENUMPROC LpEnumFunc, Pointer Arg); Inc. Gatevondottesta (HWND HDBL) Public, Zero Class (String Zinc Class, String Title);} Public Static Zero Main (String [] Args) {JNADock jna = New JnDOC ();} Public JNDOC () { GeFrem Frame = New GeFram (FrameTital); Frame.setSize (600, 100); Frame.addWindowListener (New WindowAdapter () {Public void windowClosing (WindowEvent e) {appbarRemove ();}}); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE) ); Frame.setVisible (true); AppbarSetPos (); End user 32 user32 = User32.INSTANCE; HWndGlobal = user32.FindWindowA (empty, framental); Epbaranai (); AppbarSetPos (); Frame.setLocation (0,0); } Private Zero Apps () {APPBARDATA data = new appbot.d.reference (); Data.cbSize.setValue (data.size ()); Int WM_USER = 0x0400; Data.hWnd = hWndGlobal; Data.uCallbackMessage.setValue (WM_USER + 1); UINT_PTR results = Shell32.INSTANCE.SHAppBarMessage (new DWORD (ShellAPI.ABM_NEW), data); System.out.println ("Result:" + results); } Private Zero AppsSet () {APPBARDATA data = new appbot.d.reference (); Data.cbSize.setValue (data.size ()); Data.uEdge.setValue (ShellAPI.ABE_TOP); Data.rc.top = 0; Data.rc.left = 0; Data.rc.bottom = 100; Data.rc.top = 600; UINT_PTR results = Shell32.INSTANCE.SHAppBarMessage (new DWORD (ShellAPI.ABM_SETPOS), data); System.out.println ("Result:" + results); } Remove Private Zero Apps () {APPBARDATA Data = New EpisodeData. Biopharrence (); Data.cbSize.setValue (data.size ()); Int WM_USER = 0x0400; Data.hWnd = hWndGlobal; Data.uCallbackMessage.setValue (WM_USER + 1); UINT_PTR results = Shell32.INSTANCE.SHAppBarMessage (new DWORD (ShellAPI.ABM_REMOVE), data); System.out.println ("Result:" + results); }}   

When the frame is executed, the frame is shown, but there is no error or signal of what I am doing wrong.

Note that I am just starting to use JNA and I can make rookie mistakes before calling SHAppBarMessage (ABM_SETPOS)

You have to start the new app calling call SHAppBarMessage (ABM_NEW) as shown below.

  Private Zero Apps () {APPBARDATA data = new appbot.d.reference (); Data.cbSize.setValue (data.size ()); Int WM_USER = 0x0400; Data.hWnd = hWndGlobal; Data.uCallbackMessage.setValue (WM_USER + 1); UINT_PTR results = Shell32.INSTANCE.SHAppBarMessage (new DWORD (ShellAPI.ABM_NEW), data); System.out.println ("Result:" + results); }   

Finally do not forget to remove the new appbar calling SHAppBarMessage (ABM_REMOVE)


< / Div>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -