|
1 | 1 | package com.xwintop.xJavaFxTool.utils; |
2 | 2 |
|
3 | | -import com.sun.javafx.tk.TKStage; |
4 | | -import com.sun.jna.LastErrorException; |
5 | | -import com.sun.jna.Native; |
6 | | -import com.sun.jna.Platform; |
7 | | -import com.sun.jna.Pointer; |
8 | | -import com.sun.jna.platform.win32.User32; |
9 | | -import com.sun.jna.platform.win32.WinDef; |
10 | | -import com.sun.jna.platform.win32.WinUser; |
11 | | -import com.sun.jna.win32.StdCallLibrary; |
12 | | -import com.sun.jna.win32.W32APIOptions; |
13 | 3 | import com.xwintop.xJavaFxTool.utils.Config.Keys; |
14 | 4 | import javafx.stage.Stage; |
15 | 5 | import lombok.extern.slf4j.Slf4j; |
16 | 6 |
|
17 | | -import java.lang.reflect.Method; |
18 | | - |
19 | 7 | /** |
20 | 8 | * @ClassName: StageUtils |
21 | 9 | * @Description: 更新场景工具类(解决点击任务栏图标无法最小化问题) |
|
25 | 13 |
|
26 | 14 | @Slf4j |
27 | 15 | public class StageUtils { |
28 | | - |
29 | | -// static interface ExtUser32 extends StdCallLibrary, User32 { |
30 | | -// |
31 | | -// ExtUser32 INSTANCE = (ExtUser32) Native.loadLibrary("user32", ExtUser32.class, W32APIOptions.DEFAULT_OPTIONS); |
32 | | -// |
33 | | -// WinDef.LRESULT CallWindowProcW(Pointer lpWndProc, Pointer hWnd, int msg, WinDef.WPARAM wParam, WinDef.LPARAM lParam); |
34 | | -// |
35 | | -// int SetWindowLong(HWND hWnd, int nIndex, com.sun.jna.Callback wndProc) throws LastErrorException; |
36 | | -// } |
37 | | - |
38 | | - // update default javafx stage style |
39 | | - public static void updateStageStyle(Stage stage) { |
40 | | - if (Platform.isWindows()) { |
41 | | -// Pointer pointer = getWindowPointer(stage); |
42 | | -// WinDef.HWND hwnd = new WinDef.HWND(pointer); |
43 | | -// |
44 | | -// final User32 user32 = User32.INSTANCE; |
45 | | -// int oldStyle = user32.GetWindowLong(hwnd, WinUser.GWL_STYLE); |
46 | | -// int newStyle = oldStyle | 0x00020000; // WS_MINIMIZEBOX |
47 | | -// user32.SetWindowLong(hwnd, WinUser.GWL_STYLE, newStyle); |
48 | | - } |
49 | | - } |
50 | | - |
51 | | -// private static Pointer getWindowPointer(Stage stage) { |
52 | | -// try { |
53 | | -// TKStage tkStage = stage.impl_getPeer(); |
54 | | -// Method getPlatformWindow = tkStage.getClass().getDeclaredMethod("getPlatformWindow"); |
55 | | -// getPlatformWindow.setAccessible(true); |
56 | | -// Object platformWindow = getPlatformWindow.invoke(tkStage); |
57 | | -// Method getNativeHandle = platformWindow.getClass().getMethod("getNativeHandle"); |
58 | | -// getNativeHandle.setAccessible(true); |
59 | | -// Object nativeHandle = getNativeHandle.invoke(platformWindow); |
60 | | -// return new Pointer((Long) nativeHandle); |
61 | | -// } catch (Throwable e) { |
62 | | -// e.printStackTrace(); |
63 | | -// return null; |
64 | | -// } |
65 | | -// } |
66 | | - |
67 | 16 | //加载Stage边框位置 |
68 | 17 | public static void loadPrimaryStageBound(Stage stage) { |
69 | 18 | try { |
|
0 commit comments