From 157b148e85b848657ceb80064f3bb982ae26c7d7 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 28 Sep 2019 22:55:21 +0300 Subject: [PATCH] Autosave on lock --- Crypto Notepad/MainForm.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 473ce41..d1e803b 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -34,7 +34,23 @@ public MainForm() RichTextBox.AllowDrop = true; } - /*Functions*/ + protected override void WndProc(ref Message m) + { + const int WM_SYSCOMMAND = 0x112; + const int SC_MINIMIZE = 0xF020; + + if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && settings.autoLock && PublicVar.encryptionKey.Get() != null) + { + SaveMainMenu_Click(this, new EventArgs()); + AutoLock(true); + return; + } + + base.WndProc(ref m); + } + + + #region Functions private void DecryptAES() { EnterKeyForm f2 = new EnterKeyForm();