Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Callback, When The Active Window Changed
    primarykey
    data
    text
    <pre><code>public class ActiveWindow { public delegate void ActiveWindowChangedHandler(object sender, String windowHeader,IntPtr hwnd); public event ActiveWindowChangedHandler ActiveWindowChanged; [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime); const uint WINEVENT_OUTOFCONTEXT = 0; const uint EVENT_SYSTEM_FOREGROUND = 3; [DllImport("user32.dll")] static extern bool UnhookWinEvent(IntPtr hWinEventHook); [DllImport("user32.dll")] static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags); IntPtr m_hhook; private WinEventDelegate _winEventProc; public ActiveWindow() { _winEventProc = new WinEventDelegate(WinEventProc); m_hhook = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, _winEventProc, 0, 0, WINEVENT_OUTOFCONTEXT); } void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime) { if (eventType == EVENT_SYSTEM_FOREGROUND) { if (ActiveWindowChanged != null) ActiveWindowChanged(this,GetActiveWindowTitle(hwnd),hwnd); } } private string GetActiveWindowTitle(IntPtr hwnd) { StringBuilder Buff = new StringBuilder(500); GetWindowText(hwnd, Buff, Buff.Capacity); return Buff.ToString(); } ~ActiveWindow() { UnhookWinEvent(m_hhook); } } </code></pre> <p>when i switch between the active windows i get the callback but when i maximize a minimized window i don't get a call back,</p> <p>i find a work throw to solve this problem, but i am seeking for better solution</p> <p>any help will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload