Skip to content

Instantly share code, notes, and snippets.

@LaraSQP
LaraSQP / a.cs
Last active September 22, 2021 21:31
private const int WM_NCHITTEST = 0x84;
private const int HTCAPTION = 2;
private const int HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17;
@LaraSQP
LaraSQP / a.cs
Last active September 22, 2021 21:29
private const int WM_NCHITTEST = 0x84;
protected override void WndProc( ref Message msg )
{
if( msg.Msg == WM_NCHITTEST )
{
// A result of -1 sends mouse events to the underlying window
msg.Result = (IntPtr)( -1 );
return;
}
@LaraSQP
LaraSQP / a.cs
Created September 12, 2021 06:05
var workingArea = Screen.FromHandle( Handle ).WorkingArea;
MaximizedBounds = new Rectangle( 0, 0, workingArea.Width, workingArea.Height );
WindowState = FormWindowState.Maximized;
@LaraSQP
LaraSQP / a.cs
Last active September 22, 2021 21:28
// In addition to the code below, it is necessary to either:
// 1 - Enable "Less secure app access" in Google Account -> Security
// 2 - If using 2-Step Verification, go to Google Account -> Security -> Add passwords
// then select app = Mail and device = Windows Computer to generate a password
// An alternative to the above is to authorize access for the program as shown here:
// https://developers.google.com/gmail/api/quickstart/dotnet
using var msg = new MailMessage();
using var attachment = new Attachment( @"d:\icon.png" );
msg.From = new MailAddress( "[email protected]" );
@LaraSQP
LaraSQP / a.cs
Last active September 22, 2021 21:27
protected override bool ShowFocusCues
{
get
{
return false;
}
}
@LaraSQP
LaraSQP / a.cs
Last active September 22, 2021 21:27
public const int GWL_STYLE = -16;
public const int WS_HSCROLL = 0x00100000;
public const int WS_VSCROLL = 0x00200000;
[ DllImport( "user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto ) ]
public static extern IntPtr GetWindowLong32( IntPtr hWnd, int nIndex );
[ DllImport( "user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto ) ]
public static extern IntPtr GetWindowLongPtr64( IntPtr hWnd, int nIndex );
@LaraSQP
LaraSQP / a.cs
Created September 22, 2021 21:24
private const int TCM_FIRST = 0x1300;
private const int TCM_SETPADDING = TCM_FIRST + 43;
private const int PADDING_X = 24;
private const int PADDING_Y = 2;
protected override void WndProc( ref Message m )
{
if( m.Msg == TCM_SETPADDING )
{
using SQLitePCL;
public class Database
{
protected static SQLiteConnection _db;
public BaseDb()
{
if( _db == null )
{
@LaraSQP
LaraSQP / a.cs
Created September 20, 2022 02:23
public class Example
{
public event EventHandler<string> PassString;
public event EventHandler<( Keys key, int x, bool modified )> PassMultipleValues;
private void NotifySubscribers()
{
PassString?.Invoke( this, "some text" );
PassMultipleValues?.Invoke( this, ( Keys.Up, 1, true ) );
}
@LaraSQP
LaraSQP / a.cs
Last active September 28, 2022 02:41
internal class CheckBoxEx : CheckBox
{
private const float factor = 0.6f;
private const int check = 2;
public Color DisableFore = SystemColors.GrayText;
protected override void OnPaint( PaintEventArgs pevent )
{
base.OnPaint( pevent );