From e903669e9881c4b0e2a46d1c1e95fe0703bc7558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 24 May 2025 08:22:54 +0200 Subject: [PATCH] Added: #289 Support for Aero Snap on Windows --- CHANGELOG.md | 2 + build.xml | 2 + lib/substance-fix.jar | Bin 175459 -> 175459 bytes .../flash/jna/platform/win32/Advapi32.java | 8 +- .../jna/platform/win32/Advapi32Util.java | 4 +- .../flash/jna/platform/win32/WinBase.java | 2 +- .../flash/jna/platform/win32/WinReg.java | 2 +- .../com/jpexs/video/SimpleMediaPlayer.java | 4 +- .../console/CommandLineArgumentParser.java | 2 +- .../flash/console/ContextMenuTools.java | 19 +- src/com/jpexs/decompiler/flash/gui/Main.java | 5 +- .../decompiler/flash/gui/MainFrameRibbon.java | 239 +++++++++++++----- .../gui/jna/platform/win32/Advapi32.java | 8 +- .../gui/jna/platform/win32/Advapi32Util.java | 6 +- .../flash/gui/jna/platform/win32/BITMAP.java | 2 +- .../flash/gui/jna/platform/win32/Dwmapi.java | 47 ++++ .../flash/gui/jna/platform/win32/Gdi32.java | 6 +- .../gui/jna/platform/win32/ICONINFO.java | 2 +- .../gui/jna/platform/win32/Kernel32.java | 2 +- .../win32/MEMORY_BASIC_INFORMATION.java | 2 +- .../flash/gui/jna/platform/win32/Psapi.java | 2 +- .../jna/platform/win32/SHELLEXECUTEINFO.java | 6 +- .../gui/jna/platform/win32/SHFILEINFO.java | 2 +- .../flash/gui/jna/platform/win32/Shell32.java | 2 +- .../flash/gui/jna/platform/win32/User32.java | 42 ++- .../flash/gui/jna/platform/win32/WinBase.java | 2 +- .../flash/gui/jna/platform/win32/WinDef.java | 4 +- .../flash/gui/jna/platform/win32/WinReg.java | 2 +- .../flash/gui/jna/platform/win32/WinUser.java | 20 ++ .../flash/gui/pipes/FirstInstance.java | 2 +- .../flash/gui/pipes/PipeInputStream.java | 2 +- .../flash/gui/pipes/PipeOutputStream.java | 2 +- src/com/jpexs/process/win32/Win32Process.java | 2 +- .../process/win32/Win32ProcessTools.java | 10 +- 34 files changed, 338 insertions(+), 126 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Dwmapi.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 03ad524e5..b343b6801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - Option to .bat and .sh file to enable J2D_D3D_NO_HWCHECK - [#2404] Quick find in text/script editors - show number of occurences - [#1418] Option to make main window Always on top +- [#289] Support for Aero Snap on Windows ### Fixed - [#2456] FLA export - NullPointer exception while exporting to CS4 or lower via commandline @@ -3805,6 +3806,7 @@ Major version of SWF to XML export changed to 2. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#2404]: https://www.free-decompiler.com/flash/issues/2404 [#1418]: https://www.free-decompiler.com/flash/issues/1418 +[#289]: https://www.free-decompiler.com/flash/issues/289 [#2456]: https://www.free-decompiler.com/flash/issues/2456 [#2427]: https://www.free-decompiler.com/flash/issues/2427 [#1826]: https://www.free-decompiler.com/flash/issues/1826 diff --git a/build.xml b/build.xml index 6c86b691f..bc7f19a6c 100644 --- a/build.xml +++ b/build.xml @@ -80,9 +80,11 @@ + + diff --git a/lib/substance-fix.jar b/lib/substance-fix.jar index 63f6dda774f1262de6dd87f6f53244345104c4f3..6c968cef98f3754968db4a570ee3d01fa845859c 100644 GIT binary patch delta 1367 zcmYk5X-pGA7=~xQmQspaL^+IBBlt(G3Z9e*3h{^ri>Of|5f40wQZJN*81LYHptN>D z$=)?LSnp1 zts_KB$fuc&mxPI`?wO5srXi|=8I5iew1OZ(@>uiJ7M+F=oppRzjC+Y!hz9c=zHY5v z&a)%#pX&!g`oS6!7VX|1pjDy&Fgv%{DtRmOH-lY(gWE>C^aw#=Cs|cVcpu=%l(;*8 zhUp0zrkAQ>+#SF+H|^p71@; zrY6Lu#s_@4w?>U4C$q+lK&U=r7ZBp|f>a2}1%s?4sb~)~4@zU1(U(tUW?oeTGXu^S z8r+E5qhF*6gro`bM&hkP5Ud?pzV7LDTUmcWQ>+*EciuV6N-V9D*u&&Ms2`3|!mGD_ z{_?pd)c#mp;YW!4TV$OU5G7hlV7OFha94csU#gPs%yYv;BQ!`~=2DwRE4k$FvCq;( zvzf+wo-Cvp-k2^n(`H7(DymVV3tB@hjE<+!OfPgpsdS7F(ijW9?yZ;ml59OmP0}~g zq!llw&;{bo3h?%X?W6a!7837W#nGIQuUM$hwTJ0rJ)o@O+! zmhNINQCCkB18`Q|N-vDW{!_-=>mq#!iS!ZaSXdw~>!5>TmiGsX+xU_Wsv&uxJD>`)L4!2Diu<80a=y2r*iudozlOQFN4N(*%gI z$m_(i95BiM3{PhcsPV?d50@ZazASNNF6>0OtH3NPHz>ETJ$`uH_%9~GL<4n_9 zQovlqO_KuQ#eBR>f#4GOD4(6Z6f*D(GfQFjzmIdH1A;`A16E_U)*+3{2mQzayAkG> z@v+7-Zj9v|iWKm#;3ivvUkYrmnb>ku(28rA-t=G!w8$5Z~&pp e2?r52xgZ;%$Hk*OgzBkoF+x}hY*U4#3A+S&n8 zghC4~_y7|bO$>1h7)?;)5(OnHE^&(*jiQOhnRD+%ADVvi{rCKL*3LF_XPa5fOcxAh zLQI5g4JgOO!NQh+Qg8oF1@%z2LkoyrzvArcxZi9x5@L4uPe_rchYc_as+QM8$|j4t z&{;V0=HV|u$QN)ANJy4f$Cw0*Huq}WiL-9iyP3Zf9|9a))jMQCh)dYVs>(-v1{@id zcI{6$3nASsYE_EdK6)UoY)JcP#);4ANvvaN#%2b=%z;rDwJyqKCV6Qq198P}3%0%; z^flIFAjD(96MVd})_^1X3i|axs5$5r5z>m|1O#X4FIJLOwt<;j6{*Zvs)jQ&vAU6& zuHYjhZbZGwk8(spazt$->GBy6-R%XD^62`NtiQA=H4OVZt{q|}u9hL}WJ+!|bjK*; z$@8da?fzxdeVgWwB1HR5b&rZkl3eA`T`jcA{twYJ1baYHF52lxBhrTn)MGTM&iOU< zL5}2b&~)YA6q*-~=`;tu%1E3`jRtga^Qnu`o@|;QhVJ)L+9v|3kBgoUw`hG?o_ASI z>O0b8l8$B5$#!(!UTNcPbK zj3(C6b?hSQ8)#+>&Kg?i(Vp19-*#nTVgwwX>G- zFR3*WXPuwuUFL@Wq_>e81qiY0KWB!iJ#g7~D_D)VMP66e8=H#|n@fFeHYqcS_EMG& zf)tnbAxM=)VAsA3rK1Q8fa=w8$kiT}H0K1YMYyhkwtB3an}81S9&YyQ@Y4euaB9s- z9(A1LX113@vzJGS5{DXzN7iC)j_B}5hjk@9dZxpyQ`}tDVN5AERXW6;=FJCA^XQij zxo5a}qJyK1neX5YwaF;DAcOf3Fs^yE{*Ya^!9gp7ELBU@JMKmV> diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32.java index 9a200e4ed..fffdeafbd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32.java @@ -31,14 +31,14 @@ package com.jpexs.decompiler.flash.jna.platform.win32; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLE; import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLEByReference; import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEY; import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEYByReference; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32Util.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32Util.java index fbe816222..39afe3cb8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32Util.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/Advapi32Util.java @@ -19,12 +19,12 @@ package com.jpexs.decompiler.flash.jna.platform.win32; /** * @author JPEXS */ +import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEY; +import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD; -import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEY; -import com.jpexs.decompiler.flash.jna.platform.win32.WinReg.HKEYByReference; import com.sun.jna.ptr.IntByReference; import java.util.ArrayList; import java.util.Map; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinBase.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinBase.java index 71a3a038f..99ecfa2cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinBase.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinBase.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.jna.platform.win32; +import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.Pointer; @@ -23,7 +24,6 @@ import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.platform.win32.BaseTSD; import com.sun.jna.platform.win32.WinDef; -import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.win32.StdCallLibrary; import java.util.Arrays; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinReg.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinReg.java index cdc308257..fea7656b8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinReg.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/jna/platform/win32/WinReg.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.jna.platform.win32; +import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.jpexs.decompiler.flash.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; diff --git a/libsrc/ffdec_lib/src/com/jpexs/video/SimpleMediaPlayer.java b/libsrc/ffdec_lib/src/com/jpexs/video/SimpleMediaPlayer.java index 453f9e134..6baf19ab0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/video/SimpleMediaPlayer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/video/SimpleMediaPlayer.java @@ -16,11 +16,11 @@ */ package com.jpexs.video; +import com.jpexs.decompiler.flash.jna.platform.win32.Advapi32Util; +import com.jpexs.decompiler.flash.jna.platform.win32.WinReg; import com.jpexs.helpers.Helper; import com.sun.jna.NativeLibrary; import com.sun.jna.Platform; -import com.jpexs.decompiler.flash.jna.platform.win32.Advapi32Util; -import com.jpexs.decompiler.flash.jna.platform.win32.WinReg; import java.awt.image.BufferedImage; import java.nio.ByteBuffer; import java.util.ArrayList; diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 2f4d6516d..6a40278e6 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -111,6 +111,7 @@ import com.jpexs.decompiler.flash.gui.SearchInMemory; import com.jpexs.decompiler.flash.gui.SearchInMemoryListener; import com.jpexs.decompiler.flash.gui.SwfInMemory; import com.jpexs.decompiler.flash.gui.helpers.CheckResources; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; import com.jpexs.decompiler.flash.gui.translator.Translator; import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; @@ -190,7 +191,6 @@ import com.jpexs.helpers.utf8.Utf8Helper; import com.jpexs.process.Process; import com.jpexs.process.ProcessTools; import com.sun.jna.Platform; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; import gnu.jpdf.PDFGraphics; import gnu.jpdf.PDFJob; import java.awt.Font; diff --git a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java index 661821d0b..90a2dc384 100644 --- a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java +++ b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java @@ -16,9 +16,6 @@ */ package com.jpexs.decompiler.flash.console; -import com.jpexs.helpers.utf8.Utf8Helper; -import com.sun.jna.Platform; -import com.sun.jna.WString; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Advapi32Util; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; import com.jpexs.decompiler.flash.gui.jna.platform.win32.SHELLEXECUTEINFO; @@ -26,6 +23,9 @@ import com.jpexs.decompiler.flash.gui.jna.platform.win32.Shell32; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Win32Exception; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinUser; +import com.jpexs.helpers.utf8.Utf8Helper; +import com.sun.jna.Platform; +import com.sun.jna.WString; import java.io.File; import java.util.logging.Level; import java.util.logging.Logger; @@ -107,9 +107,9 @@ public class ContextMenuTools { registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command"); registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open"); registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); } - + for (String ext : extensions) { // 1) Add to context menu of SWF @@ -124,9 +124,8 @@ public class ContextMenuTools { Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName); Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName, "", "Flash Movie"); } - + //Open with per extension - exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext + "\\OpenWithList\\" + exeName); if ((!exists) && add) { //add Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext + "\\OpenWithList\\" + exeName); @@ -134,7 +133,7 @@ public class ContextMenuTools { if (exists && (!add)) { //remove registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext + "\\OpenWithList\\" + exeName); } - + if (add) { Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, clsName, verb); } @@ -175,8 +174,8 @@ public class ContextMenuTools { } if (add) { Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb, "", verbName); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command", "", "\"" + appDir + exeName + "\" \"%1\""); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb, "MUIVerb", "@" + appDir + exeName + ",-" + muiVerbCode); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command", "", "\"" + appDir + exeName + "\" \"%1\""); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb, "MUIVerb", "@" + appDir + exeName + ",-" + muiVerbCode); } if (exists && (!add)) { //remove registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command"); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index fec40e1c9..eb5c541bb 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -50,6 +50,8 @@ import com.jpexs.decompiler.flash.gui.debugger.DebugAdapter; import com.jpexs.decompiler.flash.gui.debugger.DebugLoaderDataModified; import com.jpexs.decompiler.flash.gui.debugger.DebuggerTools; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Advapi32Util; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg; import com.jpexs.decompiler.flash.gui.pipes.FirstInstance; import com.jpexs.decompiler.flash.gui.soleditor.CookiesChangedListener; import com.jpexs.decompiler.flash.gui.soleditor.SharedObjectsStorage; @@ -82,8 +84,6 @@ import com.jpexs.helpers.Stopwatch; import com.jpexs.helpers.streams.SeekableInputStream; import com.jpexs.helpers.utf8.Utf8Helper; import com.sun.jna.Platform; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg; import java.awt.Component; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; @@ -151,7 +151,6 @@ import javax.swing.JOptionPane; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.WindowConstants; import javax.swing.filechooser.FileFilter; import javax.swing.tree.TreePath; import jsyntaxpane.DefaultSyntaxKit; diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index c91ba8d17..aae0da2c2 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -18,8 +18,16 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.Dwmapi; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.User32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinUser; import com.jpexs.decompiler.flash.treeitems.OpenableList; import com.jpexs.helpers.Helper; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import com.sun.jna.win32.StdCallLibrary; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -28,6 +36,7 @@ import java.awt.Frame; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.Insets; +import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; @@ -36,24 +45,16 @@ import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowStateListener; +import java.awt.geom.AffineTransform; import java.io.File; import java.util.List; -import javax.swing.Icon; -import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.JTree; import javax.swing.plaf.RootPaneUI; import org.pushingpixels.flamingo.api.ribbon.JRibbon; import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton; -import org.pushingpixels.substance.api.DecorationAreaType; -import org.pushingpixels.substance.api.SubstanceColorScheme; -import org.pushingpixels.substance.api.SubstanceLookAndFeel; import org.pushingpixels.substance.flamingo.ribbon.ui.SubstanceRibbonRootPaneUI; -import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities; -import org.pushingpixels.substance.internal.utils.SubstanceTitleButton; -import org.pushingpixels.substance.internal.utils.icon.SubstanceIconFactory; -import org.pushingpixels.substance.internal.utils.icon.TransitionAwareIcon; +import org.pushingpixels.substance.internal.utils.SubstanceSizeUtils; /** * @author JPEXS @@ -66,7 +67,6 @@ public final class MainFrameRibbon extends AppRibbonFrame { public MainFrameRibbon() { super(); - Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); @@ -181,70 +181,175 @@ public final class MainFrameRibbon extends AppRibbonFrame { } }); - View.centerScreenMain(this); - /*addWindowListener(new WindowAdapter() { + View.centerScreenMain(this); + + enableAeroSnap(); + } + + private void enableAeroSnap() { + if (!Platform.isWindows()) { + return; + } + Point posOnScreen = new Point(); + addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + update(); + } + + @Override + public void componentMoved(ComponentEvent e) { + update(); + } + + private void update() { + if (MainFrameRibbon.this.isVisible()) { + posOnScreen.x = MainFrameRibbon.this.getLocationOnScreen().x; + posOnScreen.y = MainFrameRibbon.this.getLocationOnScreen().y; + } + } + }); + addWindowListener(new WindowAdapter() { + private BaseTSD.LONG_PTR oldWndProc; + private StdCallLibrary.StdCallCallback newProc; + private Rectangle activeRect = new Rectangle(); + private AffineTransform trans; + @Override public void windowOpened(WindowEvent e) { RootPaneUI ui = getRootPane().getUI(); if (ui instanceof SubstanceRibbonRootPaneUI) { SubstanceRibbonRootPaneUI sui = (SubstanceRibbonRootPaneUI) ui; JComponent titlePane = sui.getTitlePane(); - final String EXTRA_COMPONENT_KIND = "substancelaf.internal.titlePane.extraComponentKind"; - Object trailing = null; - int i = 0; - int cnt = titlePane.getComponentCount(); - for (; i < cnt; i++) { - Component c = titlePane.getComponent(i); - - if (c instanceof JComponent) { - JComponent jc = (JComponent) c; - Object o = jc.getClientProperty(EXTRA_COMPONENT_KIND); - if ("TRAILING".equals("" + o)) { - trailing = o; - break; - } - } - } - if (trailing != null) { - JButton button = new SubstanceTitleButton(); - button.setFocusPainted(false); - button.setFocusable(false); - button.setOpaque(true); - button.putClientProperty(EXTRA_COMPONENT_KIND, trailing); - button.setText(null); - button.setBorder(null); - - Icon minIcon = new TransitionAwareIcon(button, - new TransitionAwareIcon.Delegate() { - @Override - public Icon getColorSchemeIcon( - SubstanceColorScheme scheme) { - return SubstanceIconFactory - .getTitlePaneIcon( - SubstanceIconFactory.IconKind.MINIMIZE, - scheme, - SubstanceCoreUtilities - .getSkin(rootPane) - .getBackgroundColorScheme( - DecorationAreaType.PRIMARY_TITLE_PANE)); - } - }, "substance.titlePane.minIcon"); - - button.setIcon(minIcon); - button.setToolTipText("Zkouska"); - button.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, - Boolean.TRUE); - - titlePane.remove(i); - titlePane.add(button, i); - titlePane.revalidate(); - } + Window window = MainFrameRibbon.this; + trans = View.getWindowDevice(window).getDefaultConfiguration().getDefaultTransform(); + if (trans == null) { + trans = new AffineTransform(); + } + + ComponentAdapter ad = new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + updateRect(); + } + + @Override + public void componentShown(ComponentEvent e) { + updateRect(); + } + + private void updateRect() { + int appButtonSize = (int) Math.round(trans.getScaleX() * Integer.getInteger("peacock.appButtonSize", 24)); + int titleIconsWidth + = 3 + SubstanceSizeUtils.getTitlePaneIconSize() //close + + 10 + SubstanceSizeUtils.getTitlePaneIconSize() //maximize / restore + + 2 + SubstanceSizeUtils.getTitlePaneIconSize() //minimize + + 2 + SubstanceSizeUtils.getTitlePaneIconSize(); //always on top + + Insets insets = titlePane.getInsets(); + if (insets == null) { + insets = new Insets(0, 0, 0, 0); + } + activeRect = new Rectangle( + insets.left + appButtonSize, + 4, + titlePane.getWidth() - titleIconsWidth - insets.right - (insets.left + appButtonSize), + titlePane.getHeight() + ); + } + }; + titlePane.addComponentListener(ad); + + ad.componentShown(null); + + WinDef.HWND hwnd = new WinDef.HWND(Native.getComponentPointer(window)); + + oldWndProc = User32.INSTANCE.GetWindowLongPtr(hwnd, WinUser.GWL_WNDPROC); + + newProc = new StdCallLibrary.StdCallCallback() { + public WinDef.LRESULT callback(WinDef.HWND hWnd, int uMsg, WinDef.WPARAM wParam, WinDef.LPARAM lParam) { + if (!User32.INSTANCE.IsWindow(hwnd)) { + return new WinDef.LRESULT(0); + } + if (uMsg == WinUser.WM_NCCALCSIZE) { + return new WinDef.LRESULT(0); + } + if (uMsg == WinUser.WM_NCHITTEST) { + int y = (short) ((lParam.longValue() >> 16) & 0xFFFF); + int x = (short) (lParam.longValue() & 0xFFFF); + + int BORDER_WIDTH = 4; + WinDef.RECT winRect = new WinDef.RECT(); + User32.INSTANCE.GetWindowRect(hWnd, winRect); + + boolean left = x >= winRect.left - BORDER_WIDTH && x < winRect.left + BORDER_WIDTH; + boolean right = x < winRect.right + BORDER_WIDTH && x >= winRect.right - BORDER_WIDTH; + boolean top = y >= winRect.top - BORDER_WIDTH && y < winRect.top + BORDER_WIDTH; + boolean bottom = y < winRect.bottom + BORDER_WIDTH && y >= winRect.bottom - BORDER_WIDTH; + + if (left && top) { + return new WinDef.LRESULT(WinUser.HTTOPLEFT); + } + if (right && top) { + return new WinDef.LRESULT(WinUser.HTTOPRIGHT); + } + if (left && bottom) { + return new WinDef.LRESULT(WinUser.HTBOTTOMLEFT); + } + if (right && bottom) { + return new WinDef.LRESULT(WinUser.HTBOTTOMRIGHT); + } + if (top) { + return new WinDef.LRESULT(WinUser.HTTOP); + } + if (bottom) { + return new WinDef.LRESULT(WinUser.HTBOTTOM); + } + if (left) { + return new WinDef.LRESULT(WinUser.HTLEFT); + } + if (right) { + return new WinDef.LRESULT(WinUser.HTRIGHT); + } + + Point p = new Point(x, y); + + p.x = (int) Math.round(p.x / trans.getScaleX()); + p.y = (int) Math.round(p.y / trans.getScaleY()); + + p.x -= posOnScreen.x; + p.y -= posOnScreen.y; + if (activeRect.contains(p)) { + return new WinDef.LRESULT(WinUser.HTCAPTION); + } + + //return new WinDef.LRESULT(WinUser.HTCLIENT); + } + return User32.INSTANCE.CallWindowProc(oldWndProc.toPointer(), hWnd, uMsg, wParam, lParam); + } + }; + + User32.INSTANCE.SetWindowLongPtr(hwnd, WinUser.GWL_WNDPROC, newProc); + + int style = User32.INSTANCE.GetWindowLong(hwnd, WinUser.GWL_STYLE); + style |= WinUser.WS_THICKFRAME; + User32.INSTANCE.SetWindowLong(hwnd, WinUser.GWL_STYLE, style); + User32.INSTANCE.SetWindowPos(hwnd, null, 0, 0, 0, 0, + WinUser.SWP_NOMOVE | WinUser.SWP_NOSIZE | WinUser.SWP_NOZORDER | WinUser.SWP_FRAMECHANGED); + + Dwmapi.MARGINS margins = new Dwmapi.MARGINS(); + margins.cxLeftWidth = 0; + margins.cxRightWidth = 0; + margins.cyTopHeight = 0; + margins.cyBottomHeight = 0; + + Dwmapi.INSTANCE.DwmExtendFrameIntoClientArea(hwnd, margins); } - } - });*/ - } - + } + }); + } + @Override public void setExtendedState(int state) { if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) { diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java index 61df9e942..ea0929911 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32.java @@ -31,14 +31,14 @@ package com.jpexs.decompiler.flash.gui.jna.platform.win32; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLEByReference; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEYByReference; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java index cb470dd81..9ffee11db 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Advapi32Util.java @@ -19,12 +19,12 @@ package com.jpexs.decompiler.flash.gui.jna.platform.win32; /** * @author JPEXS */ -import com.sun.jna.Memory; -import com.sun.jna.Native; -import com.sun.jna.Pointer; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.EVENTLOGRECORD; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEYByReference; +import com.sun.jna.Memory; +import com.sun.jna.Native; +import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import java.util.ArrayList; import java.util.Map; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BITMAP.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BITMAP.java index 462d07552..33dce2b19 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BITMAP.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/BITMAP.java @@ -16,10 +16,10 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Structure; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LONG; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LPVOID; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.WORD; +import com.sun.jna.Structure; import java.util.Arrays; import java.util.List; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Dwmapi.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Dwmapi.java new file mode 100644 index 000000000..6d2a2cd0e --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Dwmapi.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2025 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.jna.platform.win32; + +/** + * + * @author JPEXS + */ +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HWND; +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Structure; +import com.sun.jna.win32.W32APIOptions; + +public interface Dwmapi extends Library { + + Dwmapi INSTANCE = (Dwmapi) Native.loadLibrary("dwmapi", Dwmapi.class, W32APIOptions.DEFAULT_OPTIONS); + + class MARGINS extends Structure { + + public int cxLeftWidth; + public int cxRightWidth; + public int cyTopHeight; + public int cyBottomHeight; + + @Override + protected java.util.List getFieldOrder() { + return java.util.List.of("cxLeftWidth", "cxRightWidth", "cyTopHeight", "cyBottomHeight"); + } + } + + int DwmExtendFrameIntoClientArea(HWND hWnd, MARGINS pMarInset); +} diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Gdi32.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Gdi32.java index 10936e7b0..fda491a87 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Gdi32.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Gdi32.java @@ -16,9 +16,6 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.DWORD; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HBITMAP; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HDC; @@ -27,6 +24,9 @@ import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinGDI.BITMAPINFO; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinGDI.BITMAPINFOHEADER; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinGDI.RGNDATA; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/ICONINFO.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/ICONINFO.java index 856087e43..626150901 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/ICONINFO.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/ICONINFO.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Structure; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.DWORD; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HBITMAP; +import com.sun.jna.Structure; import java.util.Arrays; import java.util.List; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java index 087524775..6737657ac 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Kernel32.java @@ -16,10 +16,10 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LPVOID; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.LPVOID; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.win32.W32APIOptions; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/MEMORY_BASIC_INFORMATION.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/MEMORY_BASIC_INFORMATION.java index 52d283a6a..40a7dc0c3 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/MEMORY_BASIC_INFORMATION.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/MEMORY_BASIC_INFORMATION.java @@ -16,10 +16,10 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.SIZE_T; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.SIZE_T; import java.util.Arrays; import java.util.List; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Psapi.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Psapi.java index 18cdda0ed..214fc0423 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Psapi.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Psapi.java @@ -16,8 +16,8 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Native; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.Native; import com.sun.jna.win32.StdCallLibrary; /** diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java index 0a78192a5..87040f0ca 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHELLEXECUTEINFO.java @@ -16,13 +16,13 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.WString; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HINSTANCE; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HWND; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.WString; import java.util.Arrays; import java.util.List; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHFILEINFO.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHFILEINFO.java index f6d0286ac..a20111f9d 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHFILEINFO.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/SHFILEINFO.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HICON; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinDef.DWORD; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.HICON; import java.util.Arrays; import java.util.List; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java index 03491f798..8bf4ff428 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/Shell32.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; -import com.sun.jna.Native; import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.DWORD_PTR; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.UINT; +import com.sun.jna.Native; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/User32.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/User32.java index 06fdf6add..5c1a6371c 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/User32.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/User32.java @@ -16,12 +16,13 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.LONG_PTR; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.Callback; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.LONG_PTR; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.win32.StdCallLibrary; @@ -1445,4 +1446,41 @@ public interface User32 extends StdCallLibrary, WinUser { public static final int DI_DEFAULTSIZE = 8; int FillRect(HDC hDC, RECT lprc, HANDLE hbr); + + boolean IsWindow(HWND hWnd); + + /** + * Passes message information to the specified window procedure. + * + * @param lpPrevWndFunc + * The previous window procedure. If this value is obtained by calling + * the GetWindowLong function with the nIndex parameter set to GWL_WNDPROC + * or DWL_DLGPROC, it is actually either the address of a window or dialog + * box procedure, or a special internal value meaningful only to + * CallWindowProc. + * + * @param hWnd + * A handle to the window procedure to receive the message. + * + * @param Msg + * The message. + * + * @param wParam + * Additional message information. The content of this parameter + * depends on the value of the Msg parameter. + * + * @param lParam + * Additional message information. The content of this parameter + * depends on the value of the Msg parameter. + * + * @return The return value is the result of the message processing and depends on + * the message. + *

+ * If the function fails, the return value is zero. To get extended + * error information, call {@link Kernel32#GetLastError}. + */ + LRESULT CallWindowProc(Pointer lpPrevWndFunc, HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam); + + Pointer SetWindowLongPtr(WinDef.HWND hWnd, int nIndex, Callback wndProc); + } diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java index ddd3c2b8c..2b30a6d35 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinBase.java @@ -16,12 +16,12 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Native; import com.sun.jna.Platform; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.win32.StdCallLibrary; import java.util.Arrays; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java index 28e77ee3a..060bebc7c 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinDef.java @@ -16,12 +16,12 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.LONG_PTR; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.IntegerType; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD.LONG_PTR; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; import java.awt.Rectangle; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java index 743c8cf83..7f6a0585c 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinReg.java @@ -16,9 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.jna.platform.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; import com.sun.jna.win32.StdCallLibrary; diff --git a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java index 0f0135cf3..24affac7e 100644 --- a/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java +++ b/src/com/jpexs/decompiler/flash/gui/jna/platform/win32/WinUser.java @@ -187,6 +187,8 @@ public interface WinUser extends StdCallLibrary, WinDef { int WS_EX_LAYERED = 0x80000; int WS_EX_TRANSPARENT = 32; + + int WS_THICKFRAME = 0x00040000; int LWA_COLORKEY = 1; @@ -441,6 +443,20 @@ public interface WinUser extends StdCallLibrary, WinDef { int WM_SIZE = 0x0005; int WM_DESTROY = 0x0002; + + int WM_NCCALCSIZE = 0x0083; + int WM_NCHITTEST = 0x0084; + + int HTCLIENT = 1; + int HTCAPTION = 2; + int HTLEFT = 10; + int HTRIGHT = 11; + int HTTOP = 12; + int HTTOPLEFT = 13; + int HTTOPRIGHT = 14; + int HTBOTTOM = 15; + int HTBOTTOMLEFT = 16; + int HTBOTTOMRIGHT = 17; public static final int WM_DEVICECHANGE = 0x0219; @@ -713,6 +729,10 @@ public interface WinUser extends StdCallLibrary, WinDef { int RDW_NOFRAME = 0x0800; + int SWP_NOSIZE = 0x0001; + int SWP_NOMOVE = 0x0002; + int SWP_FRAMECHANGED = 0x0020; + /** * The retrieved handle identifies the window of the same type that is * highest in the Z order. diff --git a/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java b/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java index aa32a4321..41dd1f4e6 100644 --- a/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java +++ b/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java @@ -20,9 +20,9 @@ import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT; import com.sun.jna.Platform; import com.sun.jna.platform.win32.WinError; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT; import java.awt.Window; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/src/com/jpexs/decompiler/flash/gui/pipes/PipeInputStream.java b/src/com/jpexs/decompiler/flash/gui/pipes/PipeInputStream.java index 3e0b39116..94ccf3fb7 100644 --- a/src/com/jpexs/decompiler/flash/gui/pipes/PipeInputStream.java +++ b/src/com/jpexs/decompiler/flash/gui/pipes/PipeInputStream.java @@ -17,8 +17,8 @@ package com.jpexs.decompiler.flash.gui.pipes; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; -import com.sun.jna.Platform; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.Platform; import com.sun.jna.ptr.IntByReference; import java.io.IOException; import java.io.InputStream; diff --git a/src/com/jpexs/decompiler/flash/gui/pipes/PipeOutputStream.java b/src/com/jpexs/decompiler/flash/gui/pipes/PipeOutputStream.java index e89f58d70..d10b5945a 100644 --- a/src/com/jpexs/decompiler/flash/gui/pipes/PipeOutputStream.java +++ b/src/com/jpexs/decompiler/flash/gui/pipes/PipeOutputStream.java @@ -17,8 +17,8 @@ package com.jpexs.decompiler.flash.gui.pipes; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Kernel32; -import com.sun.jna.Platform; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.Platform; import com.sun.jna.ptr.IntByReference; import java.io.IOException; import java.io.OutputStream; diff --git a/src/com/jpexs/process/win32/Win32Process.java b/src/com/jpexs/process/win32/Win32Process.java index b4b89ec00..85c183641 100644 --- a/src/com/jpexs/process/win32/Win32Process.java +++ b/src/com/jpexs/process/win32/Win32Process.java @@ -16,9 +16,9 @@ */ package com.jpexs.process.win32; +import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.DWORD; import com.jpexs.helpers.ProgressListener; import com.jpexs.process.Process; -import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef.DWORD; import java.awt.image.BufferedImage; import java.io.File; import java.io.InputStream; diff --git a/src/com/jpexs/process/win32/Win32ProcessTools.java b/src/com/jpexs/process/win32/Win32ProcessTools.java index d785ad30b..f97959cb4 100644 --- a/src/com/jpexs/process/win32/Win32ProcessTools.java +++ b/src/com/jpexs/process/win32/Win32ProcessTools.java @@ -16,11 +16,6 @@ */ package com.jpexs.process.win32; -import com.jpexs.helpers.ProgressListener; -import com.jpexs.process.ProcessTools; -import com.sun.jna.Memory; -import com.sun.jna.NativeLong; -import com.sun.jna.Pointer; import com.jpexs.decompiler.flash.gui.jna.platform.win32.Advapi32; import com.jpexs.decompiler.flash.gui.jna.platform.win32.BITMAP; import com.jpexs.decompiler.flash.gui.jna.platform.win32.BaseTSD; @@ -37,6 +32,11 @@ import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinBase; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinDef; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT; import com.jpexs.decompiler.flash.gui.jna.platform.win32.WinNT.HANDLE; +import com.jpexs.helpers.ProgressListener; +import com.jpexs.process.ProcessTools; +import com.sun.jna.Memory; +import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.NativeLongByReference; import com.sun.jna.ptr.PointerByReference;