System\Windows\Forms\Accessibility\LabelEditNativeWindow.cs (4)
23HWND hwnd,
46var functionPointer = (delegate* unmanaged[Stdcall]<HWINEVENTHOOK, uint, HWND, int, int, uint, uint, void>)
72public bool IsHandleCreated => Handle != HWND.Null;
150private void WinEventProcCallback(HWINEVENTHOOK hWinEventHook, uint eventId, HWND hwnd, int idObject, int idChild, uint idEventThread, uint dwmsEventTime)
System\Windows\Forms\ActiveX\AxHost.cs (16)
123private HWND _hwndFocus;
814private HWND GetHandleNoCreate() => IsHandleCreated ? (HWND)Handle : default;
1246HWND handle = HWND;
1757hwnd = (ContainingControl is null) ? HWND.Null : ContainingControl.HWND,
2156parent is null ? HWND.Null : parent.HWND,
2968hWndOwner = (ContainingControl is null) ? HWND.Null : ContainingControl.HWND,
3023HWND handle = ContainingControl is null ? HWND.Null : ContainingControl.HWND;
3104_hwndFocus = (HWND)(nint)m.WParamInternal;
3136HWND hwnd = HWND.Null;
3139Application.ParkHandle(new HandleRef<HWND>(this, hwnd), DpiAwarenessContext);
3204HWND handle = GetHandleNoCreate();
3210(delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, LRESULT>)wndProc,
3235private void AttachWindow(HWND hwnd)
System\Windows\Forms\Application.ComponentManager.cs (4)
201return PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE);
231if (PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
239PInvoke.GetMessage(&msg, HWND.Null, 0, 0);
309if (!PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
System\Windows\Forms\Application.ComponentThreadContext.cs (5)
292if (PInvoke.GetMessage(&msg, HWND.Null, 0, 0))
309else if (!PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
454if (!PInvokeCore.PeekMessage(&temp, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
478HWND IMsoComponent.Interface.HwndGetWindow(msocWindow dwWhich, uint dwReserved) => HWND.Null;
System\Windows\Forms\Application.LightThreadContext.cs (4)
64if (!PInvokeCore.PeekMessage(&temp, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
83if (PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
91PInvoke.GetMessage(&msg, HWND.Null, 0, 0);
134if (!PInvokeCore.PeekMessage(&msg, HWND.Null, 0, 0, PEEK_MESSAGE_REMOVE_TYPE.PM_NOREMOVE))
System\Windows\Forms\Control.cs (57)
48IHandle<HWND>
1499HWND focusHwnd = PInvoke.GetFocus();
2409internal HWND HWNDInternal => _window.HWND;
2449HWND parentHandle = PInvoke.GetParent(this);
2450HWND lastParentHandle = parentHandle;
2520HWND prev;
2521HWND next;
2522HWND start = parent is not null ? parent.HWND : HWND;
2544internal HWND InternalHandle => !IsHandleCreated ? default : (HWND)Handle;
4627HWND.HWND_TOP,
5457HWND hwnd = (HWND)handle;
5476internal static HandleRef<HWND> GetHandleRef(HWND hwnd) => new(FromChildHandle(hwnd), hwnd);
5541HWND hwnd = PInvoke.ChildWindowFromPointEx(this, pt, (CWP_FLAGS)value);
5700for (HWND hWndChild = PInvoke.GetWindow(this, GET_WINDOW_CMD.GW_CHILD);
5702hWndChild = PInvoke.GetWindow(new HandleRef<HWND>(this, hWndChild), GET_WINDOW_CMD.GW_HWNDNEXT))
6018internal static HandleRef<HWND> GetSafeHandle(IWin32Window window)
6027HWND hwnd = (HWND)window.Handle;
7206HWND.HWND_TOP,
8655PInvokeCore.GetClientRect(new HandleRef<HWND>(_window, InternalHandle), out RECT rect);
9371PInvokeCore.MapWindowPoints((HWND)default, this, ref p);
9380PInvokeCore.MapWindowPoints(this, (HWND)default, ref p);
10032HWND parentHandle = PInvoke.GetParent(this);
10179PInvokeCore.MapWindowPoints(HWND.Null, this, ref rect);
10189PInvokeCore.MapWindowPoints(this, HWND.Null, ref rect);
10229internal virtual void ReleaseUiaProvider(HWND handle)
10841HWND.HWND_BOTTOM,
10982PInvoke.SetWindowPos(this, HWND.Null, x, y, width, height, flags);
11047private void SetParentHandle(HWND value)
11053HWND parentHandle = PInvoke.GetParent(this);
11110if (PInvoke.SetParent(this, HWND.Null).IsNull)
11241HWND.Null,
11302HWND.HWND_TOP,
11312static unsafe void PrepareDarkMode(HWND hwnd, bool darkModeEnabled)
11653PInvokeCore.MapWindowPoints(HWND.Null, PInvoke.GetParent(this), ref rect);
11744HWND hWnd = control.InternalHandle;
11783HWND parentHandle = PInvoke.GetParent(this);
11813HWND previous = HWND.HWND_TOP;
11893HWND.HWND_TOP,
11912internal void WindowAssignHandle(HWND handle, bool value)
11926HWND parentHandle = HWND;
11927HWND lastParentHandle = parentHandle;
12584HWND dialogItem = PInvoke.GetDlgItem(m.HWND, controlId);
12591dialogItem = (HWND)controlId;
12600HWND handle = NativeWindow.GetHandleFromWindowId((short)m.WParamInternal.LOWORD);
12769if ((HWND)m.WParamInternal == InternalHandle && m.LParamInternal.LOWORD == PInvoke.HTCLIENT)
12819HWND hWnd = HWND.Null;
12823hWnd = (HWND)m.LParamInternal;
13747HWND IHandle<HWND>.Handle => HWND;
13749internal HWND HWND => (HWND)Handle;
System\Windows\Forms\Controls\Buttons\CheckBoxRenderer.cs (5)
74HWND hwnd = default)
110CheckBoxState state) => DrawCheckBox(g, glyphLocation, textBounds, checkBoxText, font, flags, focused, state, HWND.Null);
121HWND hwnd)
232internal static Size GetGlyphSize(IDeviceContext deviceContext, CheckBoxState state, HWND hwnd = default)
243internal static Size GetGlyphSize(HDC hdc, CheckBoxState state, HWND hwnd)
System\Windows\Forms\Controls\Buttons\RadioButtonRenderer.cs (9)
51DrawRadioButton(g, glyphLocation, state, HWND.Null);
57HWND hwnd)
68HWND hwnd)
113DrawRadioButton(g, glyphLocation, textBounds, radioButtonText, font, flags, focused, state, HWND.Null);
125HWND hwnd)
201HWND.Null);
214HWND hwnd)
254return GetGlyphSize(hdc, state, HWND.Null);
257internal static Size GetGlyphSize(HDC hdc, RadioButtonState state, HWND hwnd)
System\Windows\Forms\Controls\ToolStrips\ToolStripPanel.FeedbackRectangle.FeedbackDropDown.cs (1)
54HWND.Null,
System\Windows\Forms\Dialogs\CommonDialogs\CommonDialog.cs (14)
22private HWND _defaultControlHwnd;
24private readonly unsafe delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, nuint> _functionPointer;
33_functionPointer = (delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, nuint>)(void*)Marshal.GetFunctionPointerForDelegate(_hookProc);
54internal LRESULT HookProcInternal(HWND hWnd, uint msg, WPARAM wparam, LPARAM lparam)
57private protected unsafe delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, nuint> HookProcFunctionPointer
68MoveToScreenCenter((HWND)hWnd);
72_defaultControlHwnd = (HWND)wparam;
73PInvoke.SetFocus((HWND)wparam);
77PInvokeCore.PostMessage((HWND)hWnd, CDM_SETDEFAULTFOCUS);
95private protected static void MoveToScreenCenter(HWND hwnd)
103HWND.HWND_TOP,
117private LRESULT OwnerWndProcInternal(HWND hWnd, uint msg, WPARAM wparam, LPARAM lparam)
146return PInvokeCore.CallWindowProc((void*)_priorWindowProcedure, (HWND)hWnd, (uint)msg, (nuint)wparam, lparam);
193HandleRef<HWND> ownerHwnd = default;
System\Windows\Forms\Dialogs\CommonDialogs\FontDialog.cs (7)
313PInvokeCore.SendMessage((HWND)hWnd, PInvokeCore.WM_CHOOSEFONT_GETLOGFONT, (WPARAM)0, ref logFont);
315int index = (int)PInvoke.SendDlgItemMessage((HWND)hWnd, (int)PInvoke.cmb4, PInvoke.CB_GETCURSEL, 0, 0);
319(HWND)hWnd,
346HWND hWndCtl = PInvoke.GetDlgItem((HWND)hWnd, (int)PInvoke.cmb4);
348hWndCtl = PInvoke.GetDlgItem((HWND)hWnd, (int)PInvoke.stc4);
389hwndOwner = (HWND)hWndOwner,
System\Windows\Forms\NativeWindow.cs (26)
14public unsafe partial class NativeWindow : MarshalByRefObject, IWin32Window, IHandle<HWND>
38private static readonly Dictionary<HWND, GCHandle> s_windowHandles = [];
39private static readonly Dictionary<short, HWND> s_windowIds = [];
90HWND handle;
153internal HWND HWND { get; private set; }
155HWND IHandle<HWND>.Handle => HWND;
236private static void AddWindowToTable(HWND handle, NativeWindow window)
278internal static short CreateWindowId(IHandle<HWND> handle)
292public void AssignHandle(IntPtr handle) => AssignHandle((HWND)handle, assignUniqueID: true);
294internal unsafe void AssignHandle(HWND hwnd, bool assignUniqueID)
340private LRESULT Callback(HWND hWnd, uint msg, WPARAM wparam, LPARAM lparam)
414HWND createResult = HWND.Null;
448(HWND)cp.Parent,
541HWND = HWND.Null;
555=> handle != IntPtr.Zero ? GetWindowFromTable((HWND)handle) : null;
560private static NativeWindow? GetWindowFromTable(HWND handle) =>
569internal static HWND GetHandleFromWindowId(short id)
571if (!s_windowIds.TryGetValue(id, out HWND handle))
573handle = HWND.Null;
613foreach ((HWND handle, GCHandle gcHandle) in s_windowHandles)
615if (!handle.IsNull && handle != (HWND)(-1))
626w?.HWND = HWND.Null;
688HWND = HWND.Null;
702private static void RemoveWindowFromDictionary(HWND hwnd, NativeWindow window)
System\Windows\Forms\SendKeys\SendKeys.cs (5)
129HWND hwnd,
182private static void AddMsgsForVK(int vk, int repeat, bool altnoctrldown, HWND hwnd)
195private static void CancelMods(ref (int HaveShift, int HaveCtrl, int HaveAlt) haveKeys, int level, HWND hwnd)
379private static void ParseKeys(string keys, HWND hwnd)
923ParseKeys(keys, (control is not null) ? (HWND)control.Handle : default);
System\Windows\Forms\ToolTip\ToolTip.cs (29)
17public partial class ToolTip : Component, IExtenderProvider, IHandle<HWND>
50private readonly Dictionary<HWND, Control> _owners = [];
257HWND IHandle<HWND>.Handle => HWND;
259internal HWND HWND => (HWND)Handle;
308HWND hwnd = PInvoke.GetActiveWindow();
309HWND rootHwnd = PInvoke.GetAncestor(control, GET_ANCESTOR_FLAGS.GA_ROOT);
991private ToolInfoWrapper<HandleRef<HWND>> GetWinTOOLINFO(IWin32Window window)
1032private HWND GetWindowFromPoint(Point screenCoords, ref bool success)
1040HWND hwndControl = PInvoke.WindowFromPoint(screenCoords);
1051return HWND.Null;
1054HWND baseHwnd = current?.HWND ?? HWND.Null;
1055HWND hwnd = HWND.Null;
1065HWND found = PInvoke.ChildWindowFromPointEx(baseHwnd, pt, CWP_FLAGS.CWP_SKIPINVISIBLE);
1108hwnd = HWND.Null;
1531HWND hwnd = GetCurrentToolHwnd();
1536ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(ownerWindow));
1741ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(win));
1751_owners.Remove((HWND)win.Handle);
1761_owners.Remove((HWND)win.Handle);
1949HWND.HWND_TOPMOST,
1957private HWND GetCurrentToolHwnd()
1970HWND hwnd = GetCurrentToolHwnd();
2096HWND.HWND_TOPMOST,
2107HWND.HWND_TOPMOST,
2246_owners.Remove((HWND)window.Handle);
System\Windows\Forms\VisualStyles\VisualStyleRenderer.cs (10)
106using PInvoke.OpenThemeDataScope handle = new(HWND.Null, className);
216DrawBackground(hdc, bounds, HWND.Null);
219internal unsafe void DrawBackground(HDC dc, Rectangle bounds, HWND hwnd = default)
245DrawBackground(hdc, bounds, clipRectangle, HWND.Null);
248internal unsafe void DrawBackground(HDC dc, Rectangle bounds, Rectangle clipRectangle, HWND hwnd)
576return GetPartSize(hdc, type, HWND.Null);
579internal unsafe Size GetPartSize(HDC dc, ThemeSizeType type, HWND hwnd = default)
865private static PInvoke.OpenThemeDataScope OpenThemeData(HWND hwnd, string classList)
883return Create(className, throwExceptionOnFail, HWND.Null);
886internal static ThemeHandle? Create(string className, bool throwExceptionOnFail, HWND hWndRef)