-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create LogForm and use on PcapController
- Loading branch information
Showing
4 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Windows.Forms; | ||
using Vanara.PInvoke; | ||
using static Vanara.PInvoke.User32; | ||
|
||
namespace Netch.Forms | ||
{ | ||
public partial class LogForm : Form | ||
{ | ||
private readonly Form _parent; | ||
|
||
public LogForm(Form parent) | ||
{ | ||
InitializeComponent(); | ||
_parent = parent; | ||
} | ||
|
||
protected override void OnShown(EventArgs e) | ||
{ | ||
base.OnShown(e); | ||
Parent_Move(null!, null!); | ||
} | ||
|
||
private void Parent_Move(object sender, EventArgs e) | ||
{ | ||
var cl = Location; | ||
var fl = _parent.Location; | ||
|
||
cl.X = fl.X + _parent.Width; | ||
cl.Y = fl.Y; | ||
Location = cl; | ||
} | ||
|
||
private void Parent_Activated(object sender, EventArgs e) | ||
{ | ||
SetWindowPos(Handle, | ||
HWND.HWND_TOPMOST, | ||
0, | ||
0, | ||
0, | ||
0, | ||
SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_SHOWWINDOW); | ||
|
||
SetWindowPos(Handle, | ||
HWND.HWND_NOTOPMOST, | ||
0, | ||
0, | ||
0, | ||
0, | ||
SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_SHOWWINDOW); | ||
} | ||
|
||
private void richTextBox1_TextChanged(object sender, System.EventArgs e) | ||
{ | ||
if (!checkBox1.Checked) | ||
return; | ||
|
||
richTextBox1.SelectionStart = richTextBox1.Text.Length; | ||
richTextBox1.ScrollToCaret(); | ||
} | ||
|
||
private void Notifycation_Load(object sender, EventArgs e) | ||
{ | ||
_parent.LocationChanged += Parent_Move; | ||
_parent.SizeChanged += Parent_Move; | ||
_parent.Activated += Parent_Activated; | ||
} | ||
|
||
protected override void OnClosing(CancelEventArgs e) | ||
{ | ||
_parent.Activated -= Parent_Activated; | ||
_parent.LocationChanged -= Parent_Move; | ||
_parent.SizeChanged -= Parent_Move; | ||
base.OnClosing(e); | ||
} | ||
} | ||
} |
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