Second attempt to fix random Taskbar reorder issue

This commit is contained in:
Usman Shafiq
2022-03-24 02:27:57 -04:00
parent 01cb6ca0e1
commit a41d65a438
3 changed files with 31 additions and 17 deletions
+4 -3
View File
@@ -30,13 +30,14 @@
{ {
this.SuspendLayout(); this.SuspendLayout();
// //
// Popup // InvisPopup
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(148, 0); this.ClientSize = new System.Drawing.Size(148, 0);
this.Name = "Popup"; this.Name = "InvisPopup";
this.Text = "Popup"; this.Opacity = 0D;
this.Text = "InvisPopup";
this.ResumeLayout(false); this.ResumeLayout(false);
} }
+7 -5
View File
@@ -14,13 +14,15 @@ namespace VRCX
{ {
public InvisPopup() public InvisPopup()
{ {
StartPosition = FormStartPosition.Manual;
//Location = new Point(-Height - 100, 0);
Location = new Point(0, 0);
InitializeComponent(); InitializeComponent();
} }
protected override void SetVisibleCore(bool value) //protected override void SetVisibleCore(bool value)
{ //{
this.WindowState = FormWindowState.Minimized; // base.SetVisibleCore(value);
base.SetVisibleCore(value); //}
}
} }
} }
+20 -9
View File
@@ -22,8 +22,8 @@ namespace VRCX
/// </summary> /// </summary>
public static void SetGlobalTheme(int theme) public static void SetGlobalTheme(int theme)
{ {
if(currentTheme == theme) //if(currentTheme == theme)
return; // return;
currentTheme = theme; currentTheme = theme;
@@ -50,14 +50,15 @@ namespace VRCX
public static void SetThemeToGlobal(List<Form> forms) public static void SetThemeToGlobal(List<Form> forms)
{ {
var activeForm = Form.ActiveForm;
InvisPopupHandler.Show(); InvisPopupHandler.Show();
foreach(Form form in forms) foreach(Form form in forms)
{ {
SetThemeToGlobal(form.Handle); SetThemeToGlobal(form.Handle);
form.Activate();
if (form.WindowState != FormWindowState.Minimized) //if (form.WindowState != FormWindowState.Minimized)
{ //{
//attempting to refresh this god forsaken title bar //attempting to refresh this god forsaken title bar
//Minimize, Downside: shows animation //Minimize, Downside: shows animation
@@ -65,12 +66,13 @@ namespace VRCX
//PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_RESTORE); //PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_RESTORE);
//Hide, Downside: reorders window to last in taskbar if not pinned //Hide, Downside: reorders window to last in taskbar if not pinned
PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_HIDE); //PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_HIDE);
PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_SHOW); //PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_SHOW);
} //}
} }
InvisPopupHandler.Close(); InvisPopupHandler.Close();
if(activeForm != null)
activeForm.Activate();
} }
private static void SetThemeToGlobal(IntPtr handle) private static void SetThemeToGlobal(IntPtr handle)
@@ -110,6 +112,11 @@ namespace VRCX
instance = new InvisPopup(); instance = new InvisPopup();
instance.Show(); instance.Show();
instance.Activate(); instance.Activate();
//PInvokeFun.ShowWindow(instance.Handle, (int)PInvokeFun.SW_TYPES.SW_SHOWNORMAL);
//PInvokeFun.SetForegroundWindow(instance.Handle);
//instance.Hide();
//instance.Show();
//instance.Activate();
} }
internal static void Close() internal static void Close()
@@ -130,6 +137,10 @@ namespace VRCX
[DllImport("user32.dll")] [DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool SetForegroundWindow(IntPtr hwnd);
internal enum SW_TYPES internal enum SW_TYPES
{ {
SW_HIDE = 0, SW_HIDE = 0,