mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using Windows.Win32.Foundation;
|
|
using Windows.Win32.UI.WindowsAndMessaging;
|
|
using static Windows.Win32.PInvoke;
|
|
|
|
namespace Netch.Forms
|
|
{
|
|
public partial class LogForm : Form
|
|
{
|
|
private readonly Form _parent;
|
|
|
|
public LogForm(Form parent)
|
|
{
|
|
InitializeComponent();
|
|
_parent = parent;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs? e)
|
|
{
|
|
base.OnLoad(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(new HWND(Handle),
|
|
new HWND(-1),
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE | SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE | SET_WINDOW_POS_FLAGS.SWP_SHOWWINDOW);
|
|
|
|
SetWindowPos(new HWND(Handle),
|
|
new HWND(-2),
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE | SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE | SET_WINDOW_POS_FLAGS.SWP_SHOWWINDOW);
|
|
}
|
|
|
|
private void richTextBox1_TextChanged(object? sender, EventArgs? e)
|
|
{
|
|
if (!checkBox1.Checked)
|
|
return;
|
|
|
|
richTextBox1.SelectionStart = richTextBox1.Text.Length;
|
|
richTextBox1.ScrollToCaret();
|
|
}
|
|
|
|
private void LogForm_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!);
|
|
}
|
|
}
|
|
} |