private IntPtr Main_Power_Hook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { // C# doesn't have definitions for power messages, so we'll get them via C++/CLI. It returns a // simple UInt16 that defines only the things we care about. var pmsg = PowerManagement.message(msg, wParam, lParam); if (pmsg == PowerManagementMessage.Suspend) { _mgr.suspend(); handled = true; } else if (pmsg == PowerManagementMessage.Resume) { var vstate = _mgr.resume(); if (vstate == ResumeVaultState.Locked) { LockVault(); } handled = true; } return(IntPtr.Zero); }
private IntPtr Passwd_Power_Hook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { // C# doesn't have definitions for power messages, so we'll get them via C++/CLI. It returns a // simple UInt16 that defines only the things we care about. var pmsg = PowerManagement.message(msg, wParam, lParam); if (pmsg == PowerManagementMessage.Resume || pmsg == PowerManagementMessage.Suspend) { // Raise the Closing event which will close our window // Don't set handled because we want other windows to process this signal, too. _Close(); } return(IntPtr.Zero); }