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;
817private HWND GetHandleNoCreate() => IsHandleCreated ? (HWND)Handle : default;
1249HWND handle = HWND;
1760hwnd = (ContainingControl is null) ? HWND.Null : ContainingControl.HWND,
2159parent is null ? HWND.Null : parent.HWND,
2971hWndOwner = (ContainingControl is null) ? HWND.Null : ContainingControl.HWND,
3026HWND handle = ContainingControl is null ? HWND.Null : ContainingControl.HWND;
3107_hwndFocus = (HWND)(nint)m.WParamInternal;
3139HWND hwnd = HWND.Null;
3142Application.ParkHandle(new HandleRef<HWND>(this, hwnd), DpiAwarenessContext);
3207HWND handle = GetHandleNoCreate();
3213(delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, LRESULT>)wndProc,
3238private 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>
1290HWND focusHwnd = PInvoke.GetFocus();
2207internal HWND HWNDInternal => _window.HWND;
2247HWND parentHandle = PInvoke.GetParent(this);
2248HWND lastParentHandle = parentHandle;
2318HWND prev;
2319HWND next;
2320HWND start = parent is not null ? parent.HWND : HWND;
2342internal HWND InternalHandle => !IsHandleCreated ? default : (HWND)Handle;
4389HWND.HWND_TOP,
5211HWND hwnd = (HWND)handle;
5230internal static HandleRef<HWND> GetHandleRef(HWND hwnd) => new(FromChildHandle(hwnd), hwnd);
5295HWND hwnd = PInvoke.ChildWindowFromPointEx(this, pt, (CWP_FLAGS)value);
5453for (HWND hWndChild = PInvoke.GetWindow(this, GET_WINDOW_CMD.GW_CHILD);
5455hWndChild = PInvoke.GetWindow(new HandleRef<HWND>(this, hWndChild), GET_WINDOW_CMD.GW_HWNDNEXT))
5771internal static HandleRef<HWND> GetSafeHandle(IWin32Window window)
5780HWND hwnd = (HWND)window.Handle;
7973PInvokeCore.GetClientRect(new HandleRef<HWND>(_window, InternalHandle), out RECT rect);
8568PInvokeCore.MapWindowPoints((HWND)default, this, ref p);
8577PInvokeCore.MapWindowPoints(this, (HWND)default, ref p);
9229HWND parentHandle = PInvoke.GetParent(this);
9377PInvokeCore.MapWindowPoints(HWND.Null, this, ref rect);
9387PInvokeCore.MapWindowPoints(this, HWND.Null, ref rect);
9427internal virtual void ReleaseUiaProvider(HWND handle)
10039HWND.HWND_BOTTOM,
10180PInvoke.SetWindowPos(this, HWND.Null, x, y, width, height, flags);
10245private void SetParentHandle(HWND value)
10251HWND parentHandle = PInvoke.GetParent(this);
10308if (PInvoke.SetParent(this, HWND.Null).IsNull)
10441HWND.Null,
10502HWND.HWND_TOP,
10512static unsafe void PrepareDarkMode(HWND hwnd, bool darkModeEnabled)
10853PInvokeCore.MapWindowPoints(HWND.Null, PInvoke.GetParent(this), ref rect);
10944HWND hWnd = control.InternalHandle;
10983HWND parentHandle = PInvoke.GetParent(this);
11013HWND previous = HWND.HWND_TOP;
11093HWND.HWND_TOP,
11112internal void WindowAssignHandle(HWND handle, bool value)
11126HWND parentHandle = HWND;
11127HWND lastParentHandle = parentHandle;
11780HWND dialogItem = PInvoke.GetDlgItem(m.HWND, controlId);
11787dialogItem = (HWND)controlId;
11796HWND handle = NativeWindow.GetHandleFromWindowId((short)m.WParamInternal.LOWORD);
11965if ((HWND)m.WParamInternal == InternalHandle && m.LParamInternal.LOWORD == PInvoke.HTCLIENT)
12015HWND hWnd = HWND.Null;
12019hWnd = (HWND)m.LParamInternal;
12935HWND IHandle<HWND>.Handle => HWND;
12937internal 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);
1951HWND.HWND_TOPMOST,
1959private HWND GetCurrentToolHwnd()
1972HWND hwnd = GetCurrentToolHwnd();
2098HWND.HWND_TOPMOST,
2109HWND.HWND_TOPMOST,
2248_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)