System\Windows\Forms\Accessibility\LabelEditNativeWindow.cs (4)
22HWND hwnd,
45var functionPointer = (delegate* unmanaged[Stdcall]<HWINEVENTHOOK, uint, HWND, int, int, uint, uint, void>)
71public bool IsHandleCreated => Handle != HWND.Null;
118private 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 (56)
48IHandle<HWND>
1311HWND focusHwnd = PInvoke.GetFocus();
2221internal HWND HWNDInternal => _window.HWND;
2261HWND parentHandle = PInvoke.GetParent(this);
2262HWND lastParentHandle = parentHandle;
2332HWND prev;
2333HWND next;
2334HWND start = parent is not null ? parent.HWND : HWND;
2356internal HWND InternalHandle => !IsHandleCreated ? default : (HWND)Handle;
4403HWND.HWND_TOP,
5225HWND hwnd = (HWND)handle;
5244internal static HandleRef<HWND> GetHandleRef(HWND hwnd) => new(FromChildHandle(hwnd), hwnd);
5309HWND hwnd = PInvoke.ChildWindowFromPointEx(this, pt, (CWP_FLAGS)value);
5467for (HWND hWndChild = PInvoke.GetWindow(this, GET_WINDOW_CMD.GW_CHILD);
5469hWndChild = PInvoke.GetWindow(new HandleRef<HWND>(this, hWndChild), GET_WINDOW_CMD.GW_HWNDNEXT))
5785internal static HandleRef<HWND> GetSafeHandle(IWin32Window window)
5794HWND hwnd = (HWND)window.Handle;
7987PInvokeCore.GetClientRect(new HandleRef<HWND>(_window, InternalHandle), out RECT rect);
8582PInvokeCore.MapWindowPoints((HWND)default, this, ref p);
8591PInvokeCore.MapWindowPoints(this, (HWND)default, ref p);
9243HWND parentHandle = PInvoke.GetParent(this);
9390PInvokeCore.MapWindowPoints(HWND.Null, this, ref rect);
9400PInvokeCore.MapWindowPoints(this, HWND.Null, ref rect);
9440internal virtual void ReleaseUiaProvider(HWND handle)
10052HWND.HWND_BOTTOM,
10193PInvoke.SetWindowPos(this, HWND.Null, x, y, width, height, flags);
10258private void SetParentHandle(HWND value)
10264HWND parentHandle = PInvoke.GetParent(this);
10321if (PInvoke.SetParent(this, HWND.Null).IsNull)
10452HWND.Null,
10513HWND.HWND_TOP,
10523static unsafe void PrepareDarkMode(HWND hwnd, bool darkModeEnabled)
10864PInvokeCore.MapWindowPoints(HWND.Null, PInvoke.GetParent(this), ref rect);
10955HWND hWnd = control.InternalHandle;
10994HWND parentHandle = PInvoke.GetParent(this);
11024HWND previous = HWND.HWND_TOP;
11104HWND.HWND_TOP,
11123internal void WindowAssignHandle(HWND handle, bool value)
11137HWND parentHandle = HWND;
11138HWND lastParentHandle = parentHandle;
11791HWND dialogItem = PInvoke.GetDlgItem(m.HWND, controlId);
11798dialogItem = (HWND)controlId;
11807HWND handle = NativeWindow.GetHandleFromWindowId((short)m.WParamInternal.LOWORD);
11976if ((HWND)m.WParamInternal == InternalHandle && m.LParamInternal.LOWORD == PInvoke.HTCLIENT)
12026HWND hWnd = HWND.Null;
12030hWnd = (HWND)m.LParamInternal;
12946HWND IHandle<HWND>.Handle => HWND;
12948internal 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);
987private ToolInfoWrapper<HandleRef<HWND>> GetWinTOOLINFO(IWin32Window window)
1028private HWND GetWindowFromPoint(Point screenCoords, ref bool success)
1036HWND hwndControl = PInvoke.WindowFromPoint(screenCoords);
1047return HWND.Null;
1050HWND baseHwnd = current?.HWND ?? HWND.Null;
1051HWND hwnd = HWND.Null;
1061HWND found = PInvoke.ChildWindowFromPointEx(baseHwnd, pt, CWP_FLAGS.CWP_SKIPINVISIBLE);
1104hwnd = HWND.Null;
1527HWND hwnd = GetCurrentToolHwnd();
1532ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(ownerWindow));
1737ToolInfoWrapper<HandleRef<HWND>> info = new(Control.GetSafeHandle(win));
1747_owners.Remove((HWND)win.Handle);
1757_owners.Remove((HWND)win.Handle);
1945HWND.HWND_TOPMOST,
1953private HWND GetCurrentToolHwnd()
1966HWND hwnd = GetCurrentToolHwnd();
2092HWND.HWND_TOPMOST,
2103HWND.HWND_TOPMOST,
2242_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)