Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
Fixed the fullscreen bug
Browse files Browse the repository at this point in the history
* Hide the widget when the user sets an app in fullscreen mode.
  • Loading branch information
Serena1432 committed Sep 7, 2022
1 parent e98e961 commit 0e78d7f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
Binary file removed FacebookWidget.v11.suo
Binary file not shown.
8 changes: 8 additions & 0 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 46 additions & 3 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,34 @@ protected override CreateParams CreateParams
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;

[System.Runtime.InteropServices.DllImport("user32.dll")]
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll")]
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
private static extern Int32 GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}

[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT Rect);

string id, cookie, position, xOffset, yOffset, response, msgNum = "0";
int phase = 1;
int phase = 1, boxWidth = 0, boxHeight = 0;
bool retrievalError = false;

void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -293,6 +311,8 @@ private void Form1_Load(object sender, EventArgs e)
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
notifyIcon1.ShowBalloonTip(5000);
}
boxWidth = this.Size.Width;
boxHeight = this.Size.Height;
}

private void Form1_MouseDown(object sender, MouseEventArgs e)
Expand Down Expand Up @@ -401,5 +421,28 @@ private void tableLayoutPanel2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://www.facebook.com/" + id);
}

private void timer3_Tick(object sender, EventArgs e)
{
IntPtr handle = GetForegroundWindow();
if (handle != null)
{
RECT Rect = new RECT();
if (GetWindowRect(handle, ref Rect))
{
int width = Rect.right - Rect.left, height = Rect.bottom - Rect.top;
if (width == Screen.PrimaryScreen.Bounds.Width && height >= Screen.PrimaryScreen.Bounds.Height - boxHeight)
{
timer2.Enabled = false;
this.Size = new Size(0, 0);
}
else
{
this.Size = new Size(boxWidth, boxHeight);
timer2.Enabled = true;
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,7 @@
AAPAAAAD4AAAB/AAAA/4AAAf/AAAP/8AAP//wAP/
</value>
</data>
<metadata name="timer3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>304, 17</value>
</metadata>
</root>

0 comments on commit 0e78d7f

Please sign in to comment.