-
-
Save Enteleform/5fee559cbd9fcdeef8b3f5c313b5e1fa to your computer and use it in GitHub Desktop.
[DisplayFusion] ToggleBorder & Maximize_RemoveBorder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//## Default (DisplayFusion) ##// | |
using System; | |
using System.Data; | |
using System.Drawing; | |
using System.Management; | |
using System.Web; | |
using System.Windows.Forms; | |
using System.Xml; | |
//## Default ##// | |
using System.Runtime.InteropServices; | |
public static class DisplayFusionFunction{ | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Run |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
public static void Run(IntPtr windowHandle){ | |
if(verify_IgnoredWindow(windowHandle)) | |
{return;} | |
if(! verify_IgnoredStyleWindow(windowHandle)){ | |
remove_Border (windowHandle); | |
maximize_Window(windowHandle); | |
} | |
else | |
{BFS.Window.Maximize(windowHandle);} | |
} | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Ignored Windows |/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
static string[] IGNORED_WINDOW_CLASSES = new string[]{ | |
//## System ##// | |
"MultitaskingViewFrame", // Windows Alt-Tab & Win-Tab Screens | |
"Progman", // Windows Desktop | |
"WorkerW", // Windows Desktop | |
"ApplicationFrameWindow", // Windows Settings | |
"Windows.UI.Core.CoreWindow", // Windows System Menus | |
"NotifyIconOverflowWindow", // Windows System Tray | |
"TaskManagerWindow", // Windows Task Manager | |
"Shell_TrayWnd", // Windows Taskbar | |
"TaskListThumbnailWnd", // Windows Taskbar Thumbnail | |
//## Apps ##// | |
"ClassicShell.CMenuContainer", // ClassicStart | |
"ExplorerBrowserOwner", // Fences | |
"WMP Skin Host", // Windows Media Player Visualizer | |
"CWmpControlCntr", // Windows Media Player Visualizer (Full-Screen) | |
}; | |
static string[] IGNORED_WINDOW_STYLE_CLASSES = new string[]{ | |
//## System ##// | |
"CabinetWClass", // Windows File Explorer | |
//## Apps ##// | |
"GomPlayer1.x", // GOM Player | |
"Chrome_WidgetWin_1", // Google Chrome | |
"ThunderRT6Main", // XYplorer | |
"ThunderRT6FormDC", // XYplorer | |
}; | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Utils |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
static bool verify_IgnoredWindow(IntPtr windowHandle){ | |
string windowClass = BFS.Window.GetClass(windowHandle); | |
return (Array.IndexOf(IGNORED_WINDOW_CLASSES, windowClass) >= 0); | |
} | |
static bool verify_IgnoredStyleWindow(IntPtr windowHandle){ | |
string windowClass = BFS.Window.GetClass(windowHandle); | |
return (Array.IndexOf(IGNORED_WINDOW_STYLE_CLASSES, windowClass) >= 0); | |
} | |
static BFS.WindowEnum.WindowStyle[] borderedWindowStyles = new BFS.WindowEnum.WindowStyle[]{ | |
BFS.WindowEnum.WindowStyle.WS_CAPTION, | |
BFS.WindowEnum.WindowStyle.WS_SYSMENU, | |
BFS.WindowEnum.WindowStyle.WS_THICKFRAME__SIZEBOX, | |
BFS.WindowEnum.WindowStyle.WS_MINIMIZEBOX, | |
BFS.WindowEnum.WindowStyle.WS_MAXIMIZEBOX, | |
}; | |
static void remove_Border(IntPtr windowHandle){ | |
BFS.WindowEnum.WindowStyle style = BFS.Window.GetWindowStyle(windowHandle); | |
foreach(BFS.WindowEnum.WindowStyle subStyle in borderedWindowStyles) | |
{style &= ~subStyle;} | |
BFS.Window.SetWindowStyle(style, windowHandle); | |
} | |
static void maximize_Window(IntPtr windowHandle){ | |
Rectangle monitor = BFS.Monitor.GetMonitorBoundsByWindow(windowHandle); | |
SetWindowPos(windowHandle, 0, monitor.X, monitor.Y, monitor.Width, monitor.Height, (SWP_NOZORDER | SWP_SHOWWINDOW)); | |
} | |
[DllImport("user32.dll")] | |
static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); | |
const short SWP_NOZORDER = 0x4; | |
const int SWP_SHOWWINDOW = 0x0040; | |
}// /DisplayFusionFunction | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//## Default (DisplayFusion) ##// | |
using System; | |
using System.Data; | |
using System.Drawing; | |
using System.Management; | |
using System.Web; | |
using System.Windows.Forms; | |
using System.Xml; | |
//## Default ##// | |
using System.Runtime.InteropServices; | |
public static class DisplayFusionFunction{ | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Run |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
public static void Run(IntPtr windowHandle){ | |
BFS.WindowEnum.WindowStyle style = BFS.Window.GetWindowStyle(windowHandle); | |
Rectangle window = BFS.Window.GetBounds (windowHandle); | |
if(verify_IgnoredWindow(windowHandle)) | |
{return;} | |
if(verify_BorderedWindow(windowHandle)) | |
{remove_Border(windowHandle, style, window);} | |
else | |
{add_Border(windowHandle, style, window);} | |
} | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Ignored Windows |/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
static string[] IGNORED_WINDOW_CLASSES = new string[]{ | |
//## System ##// | |
"MultitaskingViewFrame", // Windows Alt-Tab & Win-Tab Screens | |
"Progman", // Windows Desktop | |
"WorkerW", // Windows Desktop | |
"ApplicationFrameWindow", // Windows Settings | |
"Windows.UI.Core.CoreWindow", // Windows System Menus | |
"NotifyIconOverflowWindow", // Windows System Tray | |
"TaskManagerWindow", // Windows Task Manager | |
"Shell_TrayWnd", // Windows Taskbar | |
"TaskListThumbnailWnd", // Windows Taskbar Thumbnail | |
//## Apps ##// | |
"ClassicShell.CMenuContainer", // ClassicStart | |
"ExplorerBrowserOwner", // Fences | |
"WMP Skin Host", // Windows Media Player Visualizer | |
"CWmpControlCntr", // Windows Media Player Visualizer (Full-Screen) | |
}; | |
static string[] IGNORED_WINDOW_STYLE_CLASSES = new string[]{ | |
//## System ##// | |
"CabinetWClass", // Windows File Explorer | |
//## Apps ##// | |
"GomPlayer1.x", // GOM Player | |
"Chrome_WidgetWin_1", // Google Chrome | |
"ThunderRT6Main", // XYplorer | |
"ThunderRT6FormDC", // XYplorer | |
}; | |
/*#####################################################################################################################################################################################################################################################################################################~{*/ | |
/*//////| Utils |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////g2*/ | |
/*#####################################################################################################################################################################################################################################################################################################~}*/ | |
static bool verify_IgnoredWindow(IntPtr windowHandle){ | |
string windowClass = BFS.Window.GetClass(windowHandle); | |
return | |
( (Array.IndexOf(IGNORED_WINDOW_CLASSES, windowClass) >= 0) | |
|| (Array.IndexOf(IGNORED_WINDOW_STYLE_CLASSES, windowClass) >= 0) ); | |
} | |
static BFS.WindowEnum.WindowStyle[] borderedWindowStyles = new BFS.WindowEnum.WindowStyle[]{ | |
BFS.WindowEnum.WindowStyle.WS_CAPTION, | |
BFS.WindowEnum.WindowStyle.WS_SYSMENU, | |
BFS.WindowEnum.WindowStyle.WS_THICKFRAME__SIZEBOX, | |
BFS.WindowEnum.WindowStyle.WS_MINIMIZEBOX, | |
BFS.WindowEnum.WindowStyle.WS_MAXIMIZEBOX, | |
}; | |
static void remove_Border(IntPtr windowHandle, BFS.WindowEnum.WindowStyle style, Rectangle window){ | |
foreach(BFS.WindowEnum.WindowStyle subStyle in borderedWindowStyles) | |
{style &= ~subStyle;} | |
BFS.Window.SetWindowStyle(style, windowHandle); | |
SetWindowPos(windowHandle, 0, window.X, window.Y, window.Width, window.Height, (SWP_NOZORDER | SWP_SHOWWINDOW)); | |
} | |
static void add_Border(IntPtr windowHandle, BFS.WindowEnum.WindowStyle style, Rectangle window){ | |
Rectangle canvas = BFS.Window.GetClientRect(windowHandle); | |
foreach(BFS.WindowEnum.WindowStyle subStyle in borderedWindowStyles) | |
{style |= subStyle;} | |
BFS.Window.SetWindowStyle(style, windowHandle); | |
BFS.Window.SetSizeAndLocation(windowHandle, window.X, window.Y, canvas.Width, canvas.Height); | |
} | |
static bool verify_BorderedWindow(IntPtr windowHandle){ | |
bool hasBorderedWindow = false; | |
foreach(BFS.WindowEnum.WindowStyle style in borderedWindowStyles) | |
{hasBorderedWindow |= BFS.Window.HasWindowStyle(style, windowHandle);} | |
return hasBorderedWindow; | |
} | |
[DllImport("user32.dll")] | |
static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); | |
const short SWP_NOZORDER = 0x4; | |
const int SWP_SHOWWINDOW = 0x0040; | |
}// /DisplayFusionFunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment