471 references to NativeMethods
aspire-tray (471)
FolderApplication.cs (2)
122Marshal.ThrowExceptionForHR(NativeMethods.ParseDisplayName(path, 0, out var item, 0, out _)); 125Marshal.ThrowExceptionForHR(NativeMethods.OpenFolderAndSelectItems(item, 0, 0, 0));
NativeSmokeHarness.cs (1)
103Require(flags == NativeMethods.SafeConfirmation && (flags & 0x100) != 0, "Confirmation must default to Cancel.");
Program.cs (2)
156NativeMethods.OutputDebugString($"Tray diagnostic write failed ({ex.GetType().Name}).{Environment.NewLine}"); 158NativeMethods.OutputDebugString(message + Environment.NewLine);
TrayApplication.Actions.cs (6)
107ShowMessage("Aspire", ex.Message, NativeMethods.MbIconError); 158var accept = ConfirmForSmoke?.Invoke(title, detail, NativeMethods.SafeConfirmation) 162var result = NativeMethods.MessageBox(_modalOwner, detail, title, NativeMethods.SafeConfirmation); 189NativeCallException.Require(NativeMethods.MessageBox(_modalOwner, detail, title, flags) != 0, "MessageBoxW"); 208var result = NativeMethods.ShellExecute(_window, "open", uri.AbsoluteUri, null, null, 1);
TrayApplication.Clipboard.cs (8)
20var memory = NativeMethods.GlobalAlloc(0x2, checked((nuint)(path.Length + 1) * sizeof(char))); 24var buffer = NativeMethods.GlobalLock(memory); 30var unlocked = NativeMethods.GlobalUnlock(memory); 32NativeCallException.Require(NativeMethods.OpenClipboard(_window) != 0, "OpenClipboard"); 35NativeCallException.Require(NativeMethods.EmptyClipboard() != 0, "EmptyClipboard"); 36NativeCallException.Require(NativeMethods.SetClipboardData(13, memory) != 0, "SetClipboardData"); 41NativeCallException.Require(NativeMethods.CloseClipboard() != 0, "CloseClipboard"); 48Cleanup(NativeMethods.GlobalFree(memory) == 0, "GlobalFree(clipboard)");
TrayApplication.cs (79)
37private NativeMethods.NotifyIconData _iconData; 66if (_window != 0 && NativeMethods.PostMessage(_window, NativeMethods.RestoreMessage, 0, 0) == 0) 80if (_window != 0 && !_loopEnded && NativeMethods.PostMessage(_window, NativeMethods.QuitMessage, 0, 0) == 0) 93|| sizeof(NativeMethods.WindowClass) != 72 || sizeof(NativeMethods.Message) != 48 94|| sizeof(NativeMethods.NotifyIconData) != 976 || sizeof(NativeMethods.MenuItemInfo) != 80 95|| sizeof(NativeMethods.IconInfo) != 32 || sizeof(NativeMethods.BitmapInfo) != 44 96|| sizeof(NativeMethods.ToolInfo) != 72) 111var result = NativeMethods.GetMessage(out var message, 0, 0, 0); 118|| (_settingsWindow != 0 && NativeMethods.IsDialogMessage(_settingsWindow, ref message) != 0)) 122NativeMethods.TranslateMessage(in message); 123NativeMethods.DispatchMessage(in message); 146var controls = new NativeMethods.CommonControls 148Size = (uint)sizeof(NativeMethods.CommonControls), 151NativeCallException.Require(NativeMethods.InitCommonControlsEx(in controls) != 0, "InitCommonControlsEx"); 152_previousDpiContext = NativeMethods.SetThreadDpiAwarenessContext(-4); 154_module = NativeMethods.GetModuleHandle(null); 156_taskbarCreated = NativeMethods.RegisterWindowMessage("TaskbarCreated"); 160var windowClass = new NativeMethods.WindowClass 164NativeCallException.Require(NativeMethods.RegisterClass(ref windowClass) != 0, "RegisterClassW"); 168var window = NativeMethods.CreateWindowEx(0, ClassName, "Aspire Tray", 0, 0, 0, 0, 0, 0, 0, _module, 0); 174_iconData = new NativeMethods.NotifyIconData 176Size = (uint)sizeof(NativeMethods.NotifyIconData), Window = window, Id = 1, 177Flags = NativeMethods.NifMessage | NativeMethods.NifIcon | NativeMethods.NifTip | NativeMethods.NifShowTip, 178CallbackMessage = NativeMethods.TrayCallback 196_timerAdded = NativeMethods.SetTimer(window, TimerId, 200, 0) != 0; 202NativeCallException.Require(NativeMethods.PostMessage(window, NativeMethods.ReadyMessage, 0, 0) != 0, "PostMessageW(ready)"); 213if (NativeMethods.PostMessage(_window, NativeMethods.RefreshMessage, 0, 0) == 0) 231if (NativeMethods.ShellNotifyIcon(NativeMethods.NimAdd, ref _iconData) == 0) 240_iconData.Version = NativeMethods.NotifyIconVersion4; 241if (NativeMethods.ShellNotifyIcon(NativeMethods.NimSetVersion, ref _iconData) == 0) 264if (NativeMethods.ShellNotifyIcon(NativeMethods.NimModify, ref _iconData) == 0) 308NativeMethods.PostQuitMessage(1); 312return NativeMethods.DefWindowProc(window, message, wParam, lParam); 326case NativeMethods.ReadyMessage: 337case NativeMethods.RefreshMessage: 344case NativeMethods.RestoreMessage: 347case NativeMethods.QuitMessage: 350case NativeMethods.SettingsMessage when !_quitRequested: 354case NativeMethods.SmokeMessage when smokeSeconds is not null: 357case NativeMethods.WmTimer when wParam == TimerId: 360case NativeMethods.WmDpiChanged: 361case NativeMethods.WmSettingChange: 362case NativeMethods.WmSysColorChange: 363case NativeMethods.WmThemeChanged: 367case NativeMethods.WmMenuRightButtonUp when _menuOpen && _modalDepth == 0: 370case NativeMethods.WmMenuSelect: 373case NativeMethods.TrayCallback when !_menuOpen && !_quitRequested && _modalDepth == 0: 376if (notification is NativeMethods.WmContextMenu or NativeMethods.NinSelect or NativeMethods.NinKeySelect) 381case NativeMethods.WmClose: 382case NativeMethods.WmDestroy: 383case NativeMethods.WmEndSession when wParam != 0: 387return NativeMethods.DefWindowProc(window, message, wParam, lParam); 440Cleanup(NativeMethods.EndMenu() != 0, "EndMenu"); 450Cleanup(NativeMethods.PostMessage(popup, NativeMethods.WmClose, 0, 0) != 0, "PostMessageW(close dialog)"); 453NativeMethods.PostQuitMessage(ExitCode); 461return NativeMethods.GetWindow(owner, NativeMethods.GwEnabledPopup); 497Cleanup(NativeMethods.KillTimer(_window, TimerId) != 0, "KillTimer"); 501Cleanup(NativeMethods.ShellNotifyIcon(NativeMethods.NimDelete, ref _iconData) != 0, "Shell_NotifyIconW(NIM_DELETE)"); 515if (NativeMethods.DestroyWindow(_window) == 0) 522if (_classRegistered && NativeMethods.UnregisterClass(ClassName, _module) == 0) 530Cleanup(NativeMethods.SetThreadDpiAwarenessContext(_previousDpiContext) != 0, "SetThreadDpiAwarenessContext(restore)");
TrayApplication.Icons.cs (35)
29if (_iconAdded && NativeMethods.ShellNotifyIcon(NativeMethods.NimModify, ref _iconData) == 0) 79Size = NativeMethods.GetSystemMetricsForDpi(NativeMethods.SmCxSmallIcon, dpi); 83var original = NativeMethods.LoadImage(0, Path.Combine(AppContext.BaseDirectory, "Aspire.ico"), 84NativeMethods.ImageIcon, Size, Size, NativeMethods.LrLoadFromFile); 170var mask = NativeMethods.CreateBitmap(Size, Size, 1, 1, (nint)maskBits); 174var info = new NativeMethods.IconInfo { IsIcon = 1, Color = canvas.Handle, Mask = mask }; 175var icon = NativeMethods.CreateIconIndirect(ref info); 182_owner.Cleanup(NativeMethods.DeleteObject(mask) != 0, "DeleteObject(icon mask)"); 196_owner.Cleanup(NativeMethods.DestroyIcon(icon) != 0, "DestroyIcon"); 221var info = new NativeMethods.BitmapInfo 225Handle = NativeMethods.CreateDIBSection(0, ref info, 0, out var bits, 0, 0); 253var dc = NativeMethods.CreateCompatibleDC(0); 260previousBitmap = NativeMethods.SelectObject(dc, Handle); 264font = NativeMethods.CreateFont(-height, 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 4, 0, "Segoe MDL2 Assets"); 266previousFont = NativeMethods.SelectObject(dc, font); 268NativeCallException.Require(NativeMethods.SetTextColor(dc, 0xFFFFFF) != uint.MaxValue, "SetTextColor(menu glyph)"); 269NativeCallException.Require(NativeMethods.SetBkMode(dc, 1) != 0, "SetBkMode(menu glyph)"); // TRANSPARENT. 270var bounds = new NativeMethods.Rect { Right = _size, Bottom = _size }; 271NativeCallException.Require(NativeMethods.DrawText(dc, glyph, glyph.Length, ref bounds, 273NativeCallException.Require(NativeMethods.GdiFlush() != 0, "GdiFlush(menu glyph)"); 277var color = NativeMethods.GetSysColor(7); // COLOR_MENUTEXT. 295_owner.Cleanup(NativeMethods.SelectObject(dc, previousFont) != 0, "SelectObject(restore menu font)"); 299_owner.Cleanup(NativeMethods.SelectObject(dc, previousBitmap) != 0, "SelectObject(restore menu bitmap)"); 301_owner.Cleanup(NativeMethods.DeleteDC(dc) != 0, "DeleteDC(menu glyph)"); 304_owner.Cleanup(NativeMethods.DeleteObject(font) != 0, "DeleteObject(menu font)"); 334var dc = NativeMethods.CreateCompatibleDC(0); 339previous = NativeMethods.SelectObject(dc, Handle); 341NativeCallException.Require(NativeMethods.DrawIconEx(dc, 0, 0, icon, _size, _size, 0, 0, 3) != 0, "DrawIconEx"); 343NativeCallException.Require(NativeMethods.GdiFlush() != 0, "GdiFlush"); 349_owner.Cleanup(NativeMethods.SelectObject(dc, previous) != 0, "SelectObject(restore)"); 351_owner.Cleanup(NativeMethods.DeleteDC(dc) != 0, "DeleteDC"); 359_owner.Cleanup(NativeMethods.DeleteObject(Handle) != 0, "DeleteObject(canvas)");
TrayApplication.Menus.cs (60)
21var replacement = new Artwork(this, NativeMethods.GetDpiForWindow(_window)); 59root.StatusPosition = (uint)NativeMethods.GetMenuItemCount(root.Handle); 60Append(root.Handle, NativeMethods.MfGrayed, 0, state.Status); 66Append(root.Handle, NativeMethods.MfSeparator, 0, null); 75Append(recent, NativeMethods.MfGrayed, 0, "No recently opened AppHosts"); 77Append(recent, NativeMethods.MfSeparator, 0, null); 79Append(root.Handle, NativeMethods.MfSeparator, 0, null); 85Append(root.Handle, NativeMethods.MfSeparator, 0, null); 98var position = (uint)NativeMethods.GetMenuItemCount(parent); 121Append(submenu, NativeMethods.MfSeparator, 0, null); 132Append(row.OpenIn, NativeMethods.MfGrayed, 0, "No supported applications installed"); 134Append(submenu, NativeMethods.MfSeparator, 0, null); 135row.StatusPosition = (uint)NativeMethods.GetMenuItemCount(submenu); 136Append(submenu, NativeMethods.MfGrayed, 0, AppHostPresentation.GetMenuDetailsLabel(GetMenuStatusText(host, discoveryAvailable))); 137row.DetailsPosition = (uint)NativeMethods.GetMenuItemCount(submenu); 138Append(submenu, NativeMethods.MfGrayed, 0, AppHostPresentation.GetPathLabel(host.Id.AppHostPath)); 178NativeCallException.Require(NativeMethods.EnumThreadWindows(NativeMethods.GetCurrentThreadId(), &RedrawPopup, 0) != 0, 189var count = NativeMethods.GetClassName(window, name, 32); 193NativeCallException.Require(NativeMethods.RedrawWindow(window, 0, 0, 0x101) != 0, "RedrawWindow(menu)"); 226var submenu = NativeMethods.CreatePopupMenu(); 230Append(parent, NativeMethods.MfPopup, (nuint)submenu, title); 235if (NativeMethods.DestroyMenu(submenu) == 0) 247Append(parent, enabled ? 0u : NativeMethods.MfGrayed, id, title); 258=> NativeCallException.Require(NativeMethods.AppendMenu(menu, flags, id, Literal(text)) != 0, "AppendMenuW"); 270var info = new NativeMethods.MenuItemInfo 272Size = (uint)sizeof(NativeMethods.MenuItemInfo), Mask = NativeMethods.MiimBitmap, Bitmap = bitmap 274NativeCallException.Require(NativeMethods.SetMenuItemInfo(menu, item, byPosition ? 1 : 0, ref info) != 0, "SetMenuItemInfoW(menu bitmap)"); 279NativeCallException.Require(NativeMethods.SetMenuDefaultItem(menu, command, 0) != 0, "SetMenuDefaultItem"); 284var previous = new NativeMethods.MenuItemInfo 286Size = (uint)sizeof(NativeMethods.MenuItemInfo), Mask = NativeMethods.MiimState 288NativeCallException.Require(NativeMethods.GetMenuItemInfo(menu, id, byPosition ? 1 : 0, ref previous) != 0, "GetMenuItemInfoW(update)"); 295NativeCallException.Require(NativeMethods.SetMenuDefaultItem(menu, uint.MaxValue, 0) != 0, "SetMenuDefaultItem(clear)"); 299var info = new NativeMethods.MenuItemInfo 301Size = (uint)sizeof(NativeMethods.MenuItemInfo), 302Mask = NativeMethods.MiimString | NativeMethods.MiimState, 303Text = text, State = (previous.State & ~(3u | 0x1000u)) | (enabled ? 0u : NativeMethods.MfGrayed) 305NativeCallException.Require(NativeMethods.SetMenuItemInfo(menu, id, byPosition ? 1 : 0, ref info) != 0, "SetMenuItemInfoW"); 308NativeCallException.Require(NativeMethods.SetMenuDefaultItem(menu, id, byPosition ? 1u : 0u) != 0, 316var point = new NativeMethods.Point 323NativeCallException.Require(NativeMethods.GetCursorPos(out point) != 0, "GetCursorPos"); 329private void PrepareMenu(NativeMethods.Point point) 333NativeCallException.Require(NativeMethods.SetWindowPos(_window, 0, point.X, point.Y, 0, 0, 0x1 | 0x4 | 0x10) != 0, "SetWindowPos(tray monitor)"); 337private void TrackMenu(nint popup, NativeMethods.Point point) 342if (NativeMethods.SetForegroundWindow(_window) == 0) 350var selected = NativeMethods.TrackPopupMenuEx(popup, 351NativeMethods.TpmReturnCmd | NativeMethods.TpmRightButton, 376NativeCallException.Require(NativeMethods.PostMessage(_window, NativeMethods.WmNull, 0, 0) != 0, "PostMessageW"); 390NativeCallException.Require(NativeMethods.GetCursorPos(out var point) != 0, "GetCursorPos"); 392var selected = NativeMethods.TrackPopupMenuEx(context.Handle, 393NativeMethods.TpmReturnCmd | NativeMethods.TpmNonotify | NativeMethods.TpmRightButton | 0x1, 443var handle = NativeMethods.CreatePopupMenu(); 453owner.Cleanup(NativeMethods.DestroyMenu(Handle) != 0, "DestroyMenu");
TrayApplication.NativeSmoke.cs (110)
16internal bool IsTooltipVisibleForSmoke => _menuTooltipWindow != 0 && NativeMethods.IsWindowVisible(_menuTooltipWindow) != 0; 26var data = new NativeMethods.NotifyIconData 28Size = (uint)sizeof(NativeMethods.NotifyIconData), 34Icon = NativeMethods.LoadIcon(0, 32512) 37Program.Log($"C# NOTIFYICONDATAW architecture={RuntimeInformation.ProcessArchitecture} size={sizeof(NativeMethods.NotifyIconData)} " 42var added = NativeMethods.ShellNotifyIcon(NativeMethods.NimAdd, ref data); 46NativeCallException.Require(NativeMethods.ShellNotifyIcon(NativeMethods.NimDelete, ref data) != 0, "Shell_NotifyIconW(smoke control delete)"); 49static nint Offset(string field) => Marshal.OffsetOf<NativeMethods.NotifyIconData>(field); 84var defaultId = (nuint)NativeMethods.SendMessage(dialog, 0x400, 0, 0); 89var checkbox = NativeMethods.GetDlgItem(dialog, StopSuppressionId); 91&& NativeMethods.SendMessage(checkbox, NativeMethods.BmGetCheck, 0, 0) == 0, 93NativeSmokeHarness.Require(ReadControlText(NativeMethods.GetDlgItem(dialog, StopDetailId)) == _stopDetail, 97NativeMethods.SendMessage(checkbox, NativeMethods.BmClick, 0, 0); 98NativeSmokeHarness.Require(NativeMethods.SendMessage(checkbox, NativeMethods.BmGetCheck, 0, 0) == 1, 102var button = NativeMethods.GetDlgItem(dialog, pending.Response); 106NativeCallException.Require(NativeMethods.PostMessage(dialog, NativeMethods.WmCommand, (nuint)pending.Response, button) != 0, "PostMessageW(smoke dialog response)"); 122NativeMethods.SendMessage(_window, NativeMethods.SmokeMessage, (nuint)token, 0); 128NativeCallException.Require(NativeMethods.GetCursorPos(out var point) != 0, "GetCursorPos(smoke)"); 136NativeCallException.Require(_menuOpen && NativeMethods.EndMenu() != 0, "EndMenu(smoke)"); 143var last = (uint)(NativeMethods.GetMenuItemCount(row.Submenu) - 1); 154_tooltipFocusForSmoke = NativeMethods.GetFocus(); 158NativeCallException.Require(NativeMethods.HiliteMenuItem(_window, row.Submenu, 159details ? row.DetailsPosition : row.Pin, (details ? NativeMethods.MfByPosition : 0) | 0x80) != 0, 168NativeSmokeHarness.Require(NativeMethods.GetFocus() == _tooltipFocusForSmoke, "The tooltip stole keyboard focus."); 174NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmGetText, (nuint)text.Length, (nint)(&tool)); 177NativeCallException.Require(NativeMethods.GetWindowRect(_menuTooltipWindow, out var bounds) != 0, 179var monitor = new NativeMethods.MonitorInfo { Size = (uint)sizeof(NativeMethods.MonitorInfo) }; 180NativeCallException.Require(NativeMethods.GetMonitorInfo(NativeMethods.MonitorFromWindow(_window, 2), ref monitor) != 0, 198NativeCallException.Require(NativeMethods.ShellNotifyIcon(NativeMethods.NimDelete, ref _iconData) != 0, "Shell_NotifyIconW(smoke delete)"); 200NativeMethods.SendMessage(_window, _taskbarCreated, 0, 0); 208NativeMethods.SendMessage(_window, NativeMethods.WmDpiChanged, 0, 0); 232NativeSmokeHarness.Require(NativeMethods.GetMenuItemCount(menu.Handle) == state.AppHosts.Count + 7 + (state.ShowStatus ? 1 : 0), 237&& (ReadItem(menu.Handle, (uint)(rootTitles.Length - 2), true).Type & NativeMethods.MfSeparator) != 0, 270NativeSmokeHarness.Require((ReadItem(row.Submenu, (uint)(firstActions.Length + 1), true).Type & NativeMethods.MfSeparator) != 0, 274&& (ReadItem(row.Submenu, row.StatusPosition - 1, true).Type & NativeMethods.MfSeparator) != 0, 337var count = NativeMethods.GetMenuItemCount(menu); 372private static NativeMethods.MenuItemInfo ReadItem(nint menu, uint id, bool position) 374var info = new NativeMethods.MenuItemInfo 376Size = (uint)sizeof(NativeMethods.MenuItemInfo), 377Mask = NativeMethods.MiimState | NativeMethods.MiimBitmap | NativeMethods.MiimSubmenu | NativeMethods.MiimId | NativeMethods.MiimFType 379NativeCallException.Require(NativeMethods.GetMenuItemInfo(menu, id, position ? 1 : 0, ref info) != 0, "GetMenuItemInfoW(smoke)"); 385var info = new NativeMethods.MenuItemInfo { Size = (uint)sizeof(NativeMethods.MenuItemInfo), Mask = NativeMethods.MiimString }; 386NativeCallException.Require(NativeMethods.GetMenuItemInfo(menu, id, position ? 1 : 0, ref info) != 0, "GetMenuItemInfoW(smoke text length)"); 392NativeCallException.Require(NativeMethods.GetMenuItemInfo(menu, id, position ? 1 : 0, ref info) != 0, "GetMenuItemInfoW(smoke text)"); 399var count = NativeMethods.GetMenuItemCount(menu); 424NativeSmokeHarness.Require(target != 0 && NativeMethods.IsWindowVisible(target) != 0, "The Settings control is not visible."); 425NativeMethods.SendMessage(target, NativeMethods.BmClick, 0, 0); 431if (NativeMethods.IsWindowVisible(_settingsRefresh) != 0) 445NativeMethods.SendMessage(_settingsWindow, NativeMethods.WmClose, 0, 0); 456NativeSmokeHarness.Require(NativeMethods.IsThemeActive() == 0 || NativeMethods.IsAppThemed() != 0, 459&& ReadControlText(NativeMethods.GetDlgItem(_settingsWindow, SettingsGeneralId)) == "General" 460&& ReadControlText(NativeMethods.GetDlgItem(_settingsWindow, SettingsAboutId)) == "About", 462NativeSmokeHarness.Require(NativeMethods.SendMessage(_settingsCheckbox, NativeMethods.BmGetCheck, 0, 0) == (nint)checkState 463&& (NativeMethods.IsWindowEnabled(_settingsCheckbox) != 0) == enabled, "The native startup checkbox misrepresents backend state."); 466NativeSmokeHarness.Require((NativeMethods.IsWindowVisible(_settingsStatus) != 0) == showDetails 467&& (NativeMethods.IsWindowVisible(_settingsRefresh) != 0) == showDetails, 476for (var control = NativeMethods.GetWindow(_settingsWindow, 5); control != 0; control = NativeMethods.GetWindow(control, 2)) 479if (NativeMethods.IsWindowVisible(control) != 0) 489var length = NativeMethods.GetClassName(label, className, 32); 494NativeCallException.Require(NativeMethods.GetWindowRect(_settingsStatus, out var statusBounds) != 0, "GetWindowRect(Settings status smoke)"); 495NativeCallException.Require(NativeMethods.GetWindowRect(_settingsRefresh, out var refreshBounds) != 0, "GetWindowRect(Settings refresh smoke)"); 496NativeCallException.Require(NativeMethods.GetWindowRect(_settingsClose, out var closeBounds) != 0, "GetWindowRect(Settings close smoke)"); 497NativeCallException.Require(NativeMethods.GetWindowRect(_settingsWindow, out var windowBounds) != 0, "GetWindowRect(Settings window smoke)"); 506NativeSmokeHarness.Require(NativeMethods.SendMessage(_settingsLogo, 0x171, 0, 0) == _settingsIcon 513NativeSmokeHarness.Require(NativeMethods.IsChild(_settingsWindow, NativeMethods.GetFocus()) != 0, 520var monitor = new NativeMethods.MonitorInfo { Size = (uint)sizeof(NativeMethods.MonitorInfo) }; 521NativeCallException.Require(NativeMethods.GetMonitorInfo(NativeMethods.MonitorFromWindow(_settingsWindow, 2), ref monitor) != 0, 531NativeCallException.Require(NativeMethods.GetWindowRect(_settingsWindow, out var window) != 0, "GetWindowRect(Settings scroll smoke)"); 534NativeMethods.SetFocus(_settingsClose); 536NativeMethods.SendMessage(_settingsWindow, NativeMethods.WmVerticalScroll, 6, 0); // SB_TOP. 538NativeMethods.SendMessage(_settingsWindow, NativeMethods.WmVerticalScroll, 7, 0); // SB_BOTTOM. 539var scroll = new NativeMethods.ScrollInfo { Size = (uint)sizeof(NativeMethods.ScrollInfo), Mask = 4 }; 540NativeCallException.Require(NativeMethods.GetScrollInfo(_settingsWindow, 1, ref scroll) != 0, "GetScrollInfo(Settings scroll smoke)"); 543NativeMethods.SetFocus(_settingsCheckbox); 554NativeCallException.Require(NativeMethods.GetClientRect(_settingsWindow, out var client) != 0, "GetClientRect(Settings focus smoke)"); 555NativeCallException.Require(NativeMethods.GetWindowRect(control, out var bounds) != 0, "GetWindowRect(Settings focus smoke)"); 556var origin = new NativeMethods.Point(); 557NativeCallException.Require(NativeMethods.ClientToScreen(_settingsWindow, ref origin) != 0, "ClientToScreen(Settings focus smoke)"); 558NativeSmokeHarness.Require(NativeMethods.GetFocus() == control 565var length = NativeMethods.GetWindowTextLength(control); 569var count = NativeMethods.GetWindowText(control, buffer, text.Length);
TrayApplication.Settings.cs (72)
60var window = NativeMethods.CreateDialogIndirectParam(_module, pointer, _window, &SettingsDialogProcedure, 0); 86NativeMethods.SendMessage(_settingsWindow, 0x401, SettingsCloseId, 0); // DM_SETDEFID. 134var rect = new NativeMethods.Rect { Left = x, Top = y, Right = x + width, Bottom = y + height }; 135NativeCallException.Require(NativeMethods.MapDialogRect(dialog, ref rect) != 0, "MapDialogRect"); 136var control = NativeMethods.CreateWindowEx(0, className, text, 0x40000000 | 0x10000000 | style, 139var font = NativeMethods.SendMessage(dialog, 0x31, 0, 0); // WM_GETFONT; owned by the dialog manager. 141NativeMethods.SendMessage(control, 0x30, (nuint)font, 1); // WM_SETFONT. 147NativeMethods.ShowWindow(_settingsWindow, 9); // SW_RESTORE, including minimized windows. 151if (NativeMethods.SetForegroundWindow(_settingsWindow) == 0) 155var focus = NativeMethods.GetFocus(); 156if (NativeMethods.IsChild(_settingsWindow, focus) == 0 || NativeMethods.IsWindowEnabled(focus) == 0 157|| NativeMethods.IsWindowVisible(focus) == 0) 159var target = NativeMethods.IsWindowEnabled(_settingsCheckbox) != 0 ? _settingsCheckbox : _settingsRefresh; 160NativeMethods.SetFocus(target); 161NativeCallException.Require(NativeMethods.GetFocus() == target, "SetFocus(Settings)"); 175NativeMethods.SendMessage(_settingsCheckbox, NativeMethods.BmSetCheck, 2, 0); 187NativeMethods.SendMessage(_settingsCheckbox, NativeMethods.BmSetCheck, state.Enabled ? 1u : 0u, 0); 194NativeCallException.Require(NativeMethods.SetWindowText(_settingsStatus, message) != 0, "SetWindowTextW(Settings status)"); 197if (!showDetails && NativeMethods.GetFocus() == _settingsRefresh) 199NativeMethods.SetFocus(NativeMethods.IsWindowEnabled(_settingsCheckbox) != 0 ? _settingsCheckbox : _settingsClose); 201NativeMethods.ShowWindow(_settingsStatus, showDetails ? 5 : 0); // SW_SHOW / SW_HIDE. 202NativeMethods.ShowWindow(_settingsRefresh, showDetails ? 5 : 0); 208var moveFocus = !enabled && NativeMethods.GetFocus() == _settingsCheckbox; 209NativeMethods.EnableWindow(_settingsCheckbox, enabled ? 1 : 0); 212NativeMethods.SetFocus(_settingsStatusText.Length != 0 ? _settingsRefresh : _settingsClose); 249NativeCallException.Require(NativeMethods.DestroyWindow(_settingsWindow) != 0, "DestroyWindow(Settings)"); 258if (NativeMethods.UnhookWindowsHookEx(_settingsMenuFilter) == 0) 295case NativeMethods.WmInitDialog: 298case NativeMethods.WmCtlColorDialog: 299return NativeMethods.GetSysColorBrush(15); // COLOR_BTNFACE. 300case NativeMethods.WmCtlColorStatic: 301case NativeMethods.WmCtlColorButton: 302NativeMethods.SetTextColor((nint)wParam, NativeMethods.IsWindowEnabled(lParam) == 0 304? NativeMethods.GetSysColor(17) : NativeMethods.GetSysColor(18)); // COLOR_GRAYTEXT / COLOR_BTNTEXT. 305NativeMethods.SetBkMode((nint)wParam, 1); // TRANSPARENT. 306return NativeMethods.GetSysColorBrush(15); 307case NativeMethods.WmVerticalScroll: 308case NativeMethods.WmMouseWheel: 311case NativeMethods.WmDpiChanged: 312case NativeMethods.WmSettingChange: 313case NativeMethods.WmSysColorChange: 314case NativeMethods.WmThemeChanged: 317NativeCallException.Require(NativeMethods.PostMessage(window, NativeMethods.SettingsLayoutMessage, 0, 0) != 0, 320case NativeMethods.SettingsLayoutMessage when !_settingsInitializing && _settingsHeadingFont != 0: 324case NativeMethods.WmCommand when !_settingsInitializing && !_quitRequested: 353NativeCallException.Require(NativeMethods.GetCursorPos(out var point) != 0, "GetCursorPos(preview)"); 358case NativeMethods.WmClose: 361case NativeMethods.WmNcDestroy: 383Cleanup(NativeMethods.DestroyIcon(_settingsIcon) != 0, "DestroyIcon(Settings)"); 397var info = new NativeMethods.MenuItemInfo 399Size = (uint)sizeof(NativeMethods.MenuItemInfo), Mask = NativeMethods.MiimString, Text = text 401NativeCallException.Require(NativeMethods.SetMenuItemInfo(menu, command, 0, ref info) != 0, "SetMenuItemInfoW(Settings shortcut)"); 409_settingsMenuFilter = NativeMethods.SetWindowsHookEx(-1, &SettingsMenuFilter, 0, NativeMethods.GetCurrentThreadId()); 413private bool HandleSettingsShortcut(in NativeMethods.Message message) 416&& (message.Window == _settingsWindow || NativeMethods.IsChild(_settingsWindow, message.Window) != 0)); 417if (_quitRequested || _modalDepth != 0 || !localFocus || message.Id != NativeMethods.WmKeyDown || message.WParam != 0xBC 418|| NativeMethods.GetKeyState(0x11) >= 0 || NativeMethods.GetKeyState(0x12) < 0) 429NativeCallException.Require(NativeMethods.EndMenu() != 0, "EndMenu(Settings shortcut)"); 431NativeCallException.Require(NativeMethods.PostMessage(_window, NativeMethods.SettingsMessage, 0, 0) != 0, "PostMessageW(Settings shortcut)"); 441&& application.HandleSettingsShortcut(in *(NativeMethods.Message*)lParam)) 457return NativeMethods.CallNextHookEx(0, code, wParam, lParam);
TrayApplication.SettingsAppearance.cs (46)
8private readonly Dictionary<nint, NativeMethods.Rect> _settingsControlBounds = []; 10private NativeMethods.Rect _settingsGeneralBounds; 11private NativeMethods.Rect _settingsAboutBounds; 18var dpi = NativeMethods.GetDpiForWindow(_settingsWindow); 19var font = NativeMethods.CreateFont(-checked((int)((9 * dpi + 36) / 72)), 0, 0, 0, 700, 0, 0, 0, 1, 0, 0, 5, 0, "Segoe UI"); 23NativeMethods.SendMessage(control, 0x30, (nuint)font, 1); // WM_SETFONT. 28Cleanup(NativeMethods.DeleteObject(_settingsHeadingFont) != 0, "DeleteObject(Settings font)"); 33var icon = NativeMethods.LoadImage(0, Path.Combine(AppContext.BaseDirectory, "Aspire.ico"), 34NativeMethods.ImageIcon, size, size, NativeMethods.LrLoadFromFile); 36NativeMethods.SendMessage(_settingsLogo, 0x170, (nuint)icon, 0); // STM_SETICON; the static control borrows the icon. 39Cleanup(NativeMethods.DestroyIcon(_settingsIcon) != 0, "DestroyIcon(Settings logo)"); 86NativeCallException.Require(NativeMethods.GetWindowRect(_settingsWindow, out var window) != 0, "GetWindowRect(Settings)"); 87NativeCallException.Require(NativeMethods.GetClientRect(_settingsWindow, out var client) != 0, "GetClientRect(Settings)"); 88var monitor = new NativeMethods.MonitorInfo { Size = (uint)sizeof(NativeMethods.MonitorInfo) }; 89NativeCallException.Require(NativeMethods.GetMonitorInfo(NativeMethods.MonitorFromWindow(_settingsWindow, 2), ref monitor) != 0, 95var scroll = new NativeMethods.ScrollInfo 97Size = (uint)sizeof(NativeMethods.ScrollInfo), Mask = 1 | 2 | 4, // SIF_RANGE | SIF_PAGE | SIF_POS. 100NativeMethods.SetScrollInfo(_settingsWindow, 1, in scroll, 1); // SB_VERT; hidden when all content fits. 102NativeCallException.Require(NativeMethods.GetClientRect(_settingsWindow, out client) != 0, "GetClientRect(Settings scroll)"); 107NativeCallException.Require(NativeMethods.SetWindowPos(_settingsWindow, 0, x, y, width, height, 0x4 | 0x10) != 0, 110EnsureSettingsControlVisible(NativeMethods.GetFocus()); 113private NativeMethods.Rect SettingsRect(int x, int y, int width, int height) 115var dpi = NativeMethods.GetDpiForWindow(_settingsWindow); 124NativeCallException.Require(NativeMethods.SetWindowPos(control, 0, bounds.Left, bounds.Top - _settingsScrollPosition, 127NativeCallException.Require(NativeMethods.RedrawWindow(_settingsWindow, 0, 0, 1 | 4 | 0x80) != 0, 137NativeCallException.Require(NativeMethods.GetClientRect(_settingsWindow, out var client) != 0, "GetClientRect(Settings focus)"); 156var scroll = new NativeMethods.ScrollInfo { Size = (uint)sizeof(NativeMethods.ScrollInfo), Mask = 4, Position = position }; 157NativeMethods.SetScrollInfo(_settingsWindow, 1, in scroll, 1); 163NativeCallException.Require(NativeMethods.GetClientRect(_settingsWindow, out var client) != 0, "GetClientRect(Settings scroll)"); 165if (message == NativeMethods.WmMouseWheel) 168NativeCallException.Require(NativeMethods.GetWheelScrollLines(0x68, 0, ref lines, 0) != 0, 177var scroll = new NativeMethods.ScrollInfo { Size = (uint)sizeof(NativeMethods.ScrollInfo), Mask = 0x10 }; // SIF_TRACKPOS. 181NativeCallException.Require(NativeMethods.GetScrollInfo(_settingsWindow, 1, ref scroll) != 0, "GetScrollInfo(Settings)"); 199var dc = NativeMethods.GetDC(_settingsWindow); 201var previous = NativeMethods.SelectObject(dc, NativeMethods.SendMessage(_settingsWindow, 0x31, 0, 0)); 205var rect = new NativeMethods.Rect { Right = units.Right }; 206NativeCallException.Require(NativeMethods.DrawText(dc, text, text.Length, ref rect, 214Cleanup(NativeMethods.SelectObject(dc, previous) != 0, "SelectObject(Settings measure restore)"); 216Cleanup(NativeMethods.ReleaseDC(_settingsWindow, dc) != 0, "ReleaseDC(Settings measure)"); 224Cleanup(NativeMethods.DeleteObject(_settingsHeadingFont) != 0, "DeleteObject(Settings font)");
TrayApplication.StopConfirmation.cs (13)
32var accept = ConfirmForSmoke?.Invoke("Stop AppHost", _stopDetail, NativeMethods.SafeConfirmation) 40result = NativeMethods.DialogBoxIndirectParam(_module, pointer, _modalOwner, &StopDialogProcedure, 0); 68case NativeMethods.WmInitDialog: 74NativeMethods.SendMessage(dialog, 0x401, 2, 0); // DM_SETDEFID. 75NativeMethods.SetFocus(cancel); 77case NativeMethods.WmCommand when (wParam & 0xFFFF) is 1 or 2: 80&& NativeMethods.SendMessage(NativeMethods.GetDlgItem(dialog, StopSuppressionId), 81NativeMethods.BmGetCheck, 0, 0) == 1; 82NativeCallException.Require(NativeMethods.EndDialog(dialog, result) != 0, "EndDialog(Stop)"); 84case NativeMethods.WmClose: 85NativeCallException.Require(NativeMethods.EndDialog(dialog, 2) != 0, "EndDialog(Cancel)"); 107NativeMethods.EndDialog(dialog, 2);
TrayApplication.Tooltips.cs (37)
26&& menu != 0 && command == 0 && (flags & (NativeMethods.MfPopup | NativeMethods.MfSeparator)) == 0 40var delay = NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmGetDelayTime, 3, 0); 53_menuTooltipWindow = NativeMethods.CreateWindowEx( 58NativeCallException.Require(NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmAddTool, 0, (nint)(&tool)) != 0, 62private NativeMethods.ToolInfo MenuTooltipInfo() => new() 64Size = (uint)sizeof(NativeMethods.ToolInfo), 87NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmUpdateTipText, 0, (nint)(&tool)); 94NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmTrackActivate, 1, (nint)(&tool)); 105NativeCallException.Require(NativeMethods.GetWindowRect(_menuTooltipWindow, out var bounds) != 0, 107var monitor = new NativeMethods.MonitorInfo { Size = (uint)sizeof(NativeMethods.MonitorInfo) }; 108NativeCallException.Require(NativeMethods.GetMonitorInfo(NativeMethods.MonitorFromWindow(_window, 2), ref monitor) != 0, 112NativeCallException.Require(NativeMethods.SetWindowPos(_menuTooltipWindow, 0, x, y, 0, 0, 116private void PositionMenuTooltip(HostRow row, ref NativeMethods.ToolInfo tool) 118NativeCallException.Require(NativeMethods.GetMenuItemRect(0, row.Submenu, 0, out var first) != 0, 120NativeCallException.Require(NativeMethods.GetMenuItemRect(0, row.Submenu, row.DetailsPosition, out var last) != 0, 122var monitor = new NativeMethods.MonitorInfo { Size = (uint)sizeof(NativeMethods.MonitorInfo) }; 123NativeCallException.Require(NativeMethods.GetMonitorInfo(NativeMethods.MonitorFromWindow(_window, 2), ref monitor) != 0, 125var dpi = NativeMethods.GetDpiForWindow(_window); 129NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmSetMaxTipWidth, 0, maximumWidth); 131fixed (NativeMethods.ToolInfo* info = &tool) 133size = (nuint)NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmGetBubbleSize, 0, (nint)info); 146NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmTrackPosition, 0, 157NativeMethods.SendMessage(_menuTooltipWindow, NativeMethods.TtmTrackActivate, 0, (nint)(&tool)); 166if (NativeMethods.DestroyWindow(_menuTooltipWindow) == 0)