This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
CC-Clicker/CC-Clicker 2.0/LocForm.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2019-11-10 00:28:55 +01:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CC_Clicker_2._0
{
public partial class LocForm : Form
{
public int X;
public int Y;
public LocForm() => InitializeComponent();
bool close;
private void LocForm_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = !close;
private void LocForm_MouseClick(object sender, MouseEventArgs e)
{
X = Cursor.Position.X;
Y = Cursor.Position.Y;
close = true;
DialogResult = DialogResult.OK;
Close();
}
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOMOVE = 0x0002;
const uint TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private void LocForm_Load(object sender, EventArgs e) => SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}
}