public void enableSettings() { User32.INSTANCE.SetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE, settingWl); }
public void start(Stage stage) { Scene scene = new Scene(new Pane(new Label("Hello World"))); stage.initStyle(StageStyle.UNDECORATED); stage.setTitle("Find this window"); stage.setScene(scene); stage.show(); long lhwnd = com.sun.glass.ui.Window.getWindows().get(0).getNativeWindow(); Pointer lpVoid = new Pointer(lhwnd); HWND hwnd = new HWND(lpVoid); final User32 user32 = User32.INSTANCE; int oldStyle = user32.GetWindowLong(hwnd, GWL_STYLE); System.out.println(Integer.toBinaryString(oldStyle)); int newStyle = oldStyle | 0x00020000;//WS_MINIMIZEBOX System.out.println(Integer.toBinaryString(newStyle)); user32.SetWindowLong(hwnd, GWL_STYLE, newStyle); }
private void setTransparent(Component w) { this.componentHwnd = getHWnd(w); this.settingWl = User32.INSTANCE.GetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE); int transparentWl = User32.INSTANCE.GetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE) | WinUser.WS_EX_LAYERED | WinUser.WS_EX_TRANSPARENT; User32.INSTANCE.SetWindowLong(componentHwnd, WinUser.GWL_EXSTYLE, transparentWl); }
@Override public void run() { HWND hWnd = getHWnd(w); User32 user = User32.INSTANCE; int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE); byte level = (byte)((int)(255 * alpha) & 0xFF); if (usingUpdateLayeredWindow(w)) { // If already using UpdateLayeredWindow, continue to // do so BLENDFUNCTION blend = new BLENDFUNCTION(); blend.SourceConstantAlpha = level; blend.AlphaFormat = WinUser.AC_SRC_ALPHA; user.UpdateLayeredWindow(hWnd, null, null, null, null, null, 0, blend, WinUser.ULW_ALPHA); } else if (alpha == 1f) { flags &= ~WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } else { flags |= WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); user.SetLayeredWindowAttributes(hWnd, 0, level, WinUser.LWA_ALPHA); } setForceHeavyweightPopups(w, alpha != 1f); storeAlpha(w, level); } });
public void run() { HWND hWnd = getHWnd(w); User32 user = User32.INSTANCE; int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE); byte level = (byte)((int)(255 * alpha) & 0xFF); if (usingUpdateLayeredWindow(w)) { // If already using UpdateLayeredWindow, continue to // do so BLENDFUNCTION blend = new BLENDFUNCTION(); blend.SourceConstantAlpha = level; blend.AlphaFormat = WinUser.AC_SRC_ALPHA; user.UpdateLayeredWindow(hWnd, null, null, null, null, null, 0, blend, WinUser.ULW_ALPHA); } else if (alpha == 1f) { flags &= ~WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } else { flags |= WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); user.SetLayeredWindowAttributes(hWnd, 0, level, WinUser.LWA_ALPHA); } setForceHeavyweightPopups(w, alpha != 1f); storeAlpha(w, level); } });
/** * Sets transparency of the window. * @param alpha 0..255 alpha attribute. * @throws Win32Exception WIN32 call has failed. * @throws AutomationException Something is wrong in automation. */ public void setTransparency(int alpha) throws Win32Exception, AutomationException { WinDef.HWND hwnd = this.getNativeWindowHandle(); if (user32.SetWindowLong( hwnd, User32.GWL_EXSTYLE, User32.WS_EX_LAYERED) == 0) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } if (!user32.SetLayeredWindowAttributes( hwnd, 0, (byte)alpha, User32.LWA_ALPHA)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } }
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
public void run() { User32 user = User32.INSTANCE; HWND hWnd = getHWnd(w); int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE); JRootPane root = ((RootPaneContainer)w).getRootPane(); JLayeredPane lp = root.getLayeredPane(); Container content = root.getContentPane(); if (content instanceof W32TransparentContentPane) { ((W32TransparentContentPane)content).setTransparent(transparent); } else if (transparent) { W32TransparentContentPane w32content = new W32TransparentContentPane(content); root.setContentPane(w32content); lp.add(new RepaintTrigger(w32content), JLayeredPane.DRAG_LAYER); } if (transparent && !usingUpdateLayeredWindow(w)) { flags |= WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } else if (!transparent && usingUpdateLayeredWindow(w)) { flags &= ~WinUser.WS_EX_LAYERED; user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags); } setLayersTransparent(w, transparent); setForceHeavyweightPopups(w, transparent); setDoubleBuffered(w, !transparent); } });
int newStyle = oldStyle & ~0x00400000; //bitwise not WS_DLGFRAME means remove the style newStyle = newStyle & ~0x00040000;//WS_THICKFRAME user32.SetWindowLong(hwnd, GWL_STYLE, newStyle);