[BUG] -systemtray startup parameter overrides user setting sta_close for SC_MINIMIZE handling

Author: timwesselsCreated Apr 26, 2026Updated Sep 17, 2026

Is there an existing issue for this?

  • I have searched the existing issues

Is the issue reproducible in Notepad++ without plugin?

  • I have tried Notepad++ without plugin

Is the issue reproducible in portable version of Notepad++?

  • I have tried portable version of Notepad++

Does the issue affect SciTE?

  • I have tried SciTE

Description of the Issue

When Notepad++ is launched with the -systemtray startup parameter (typical use case: an autostart shortcut that preloads Notepad++ into the system tray on Windows login), the user-configured System tray setting is silently overridden. Specifically, a user who selected sta_close ("Close to" — meaning minimize → taskbar, X-button → tray) finds that every minimize click is routed to the tray instead, ignoring the configured behavior.

The cause is the internal _isPrelaunch flag, which is set when -systemtray is passed and OR'd into the minimize-to-tray condition in the WM_SYSCOMMAND handler. The flag is only ever cleared at runtime by the tray context menu's "Close" item, which has the side effect of also terminating Notepad++ if the window is hidden — leaving users with no in-app way to undo the override without quitting.

Steps To Reproduce

  1. In Notepad++, go to Settings → Preferences → MISC → System tray and select "Close to" (sta_close, persisted in config.xml as <GUIConfig name="TrayIcon">2</GUIConfig>).
  2. Quit Notepad++ completely.
  3. Launch Notepad++ from a command line with the -systemtray parameter:
"C:\Program Files\Notepad++\notepad++.exe" -systemtray

Notepad++ appears in the system tray, no visible window. 4. Click the tray icon to bring Notepad++ to the foreground. 5. Click the minimize button (_) on the title bar.

Current Behavior

Notepad++ minimizes to the system tray. The user-configured sta_close setting is ignored.

This persists for the entire lifetime of the process — every minimize click goes to the tray, regardless of how many times the user restores Notepad++ from tray and minimizes again.

Expected Behavior

Notepad++ minimizes to the Windows taskbar, as configured by the user (sta_close: minimize → taskbar, X → tray).

The -systemtray parameter should only control the initial startup state (window hidden + tray icon visible). Once Notepad++ is running, the user's configured tray-behavior setting should be respected for all subsequent minimize/close events.

Debug Information

bash
Notepad++ v8.9.3   (64-bit)
Build time: Mar 20 2026 - 00:44:25
Scintilla/Lexilla included: 5.6.0/5.4.7
Boost Regex included: 1_90
pugixml included: 1.15
nlohmann JSON included: 3.12.0
Path: C:\Program Files\Notepad++\notepad++.exe
Command Line: -noPlugin -systemtray
Admin mode: OFF
Local Conf mode: OFF
Cloud Config: OFF
WinGUp: present
disableNppAutoUpdate.xml: absent
Periodic Backup: ON
Placeholders: OFF
Scintilla Rendering Mode: SC_TECHNOLOGY_DEFAULT (0)
Multi-instance Mode: monoInst
asNotepad: OFF
File Status Auto-Detection: cdEnabledNew (for current file/tab only)
Dark Mode: OFF
Display Info:
    primary monitor: 2560x1440, scaling 100%
    visible monitors count: 1
    installed Display Class adapters: 
        0000: Description - Intel(R) Iris(R) Xe Graphics
        0000: DriverVersion - 32.0.101.7077
OS Name: Windows 11 Pro (64-bit)
OS Version: 25H2
OS Build: 26200.8246
Current ANSI codepage: 1252
Plugins: none

Anything else?

Suggested fix

Option A (minimal change): Remove || _pPublicInterface->isPrelaunch() from the condition at NppBigSwitch.cpp:2839. The -systemtray parameter would then only control the initial startup state, and the user's setting would be respected at runtime.

Behavioral change matrix:

Startup User setting Current behavior After fix
-systemtray sta_close (2) minimize → tray (bug) minimize → taskbar ✓
-systemtray sta_minimize (1) minimize → tray minimize → tray (unchanged)
-systemtray sta_minimize_close (3) minimize → tray minimize → tray (unchanged)
-systemtray sta_none (0) minimize → tray minimize → taskbar (changed)

The last row is the only behavioral change for non-buggy cases.

Option B (more conservative, preserves sta_none behavior): Keep the condition, but reset _isPrelaunch to false automatically the first time the user explicitly restores the window from tray (e.g. inside the NPPM_INTERNAL_MINIMIZED_TRAY / WM_LBUTTONUP handler at NppBigSwitch.cpp:2891). This preserves the current sta_none behavior, and aligns with the apparent semantic intent of _isPrelaunch as a startup-only state.

Either option resolves the bug without breaking expected behavior.

Related issues and PRs (for context)

A thorough search of existing issues, PRs, and the Notepad++ community forum did not find a direct duplicate of this report. The following are thematically adjacent and may be useful context for maintainers:

  • PR #15617 (merged 2024-10-11) — initial introduction of the "Close to system tray" preference. The _isMinimizedToTray setting that this issue references originates here.
  • PR #15785 (merged 2024-11-14) — extension of the setting into the current 4-value combo box (sta_none / sta_minimize / sta_close / sta_minimize_close). This is the PR that established the user-facing semantics that the -systemtray parameter currently overrides.
  • #15771 (closed 2024-11-07) — feature request that motivated the addition of sta_minimize_close.
  • #17373 (closed 2026-01-10) — different issue, but same usage pattern (Notepad++ launched via -systemtray autostart). Confirms that the autostart-via-tray workflow is a real use case in the wild.
  • #8484 (open since 2020-06-26) — older issue, also related to clean shutdown of -systemtray-launched Notepad++.

Why portable / SciTE checkboxes are not checked

  • Portable version not tested: This is a code-level bug clearly localized in NppBigSwitch.cpp, with the same source code in installed and portable versions. The portable test would not produce additional information.
  • SciTE not tested: SciTE has no system-tray functionality and no -systemtray command-line option, so the bug cannot exist there to begin with — the test is not applicable.

Workaround (informational, for users hitting this issue today)

It is possible to clear _isPrelaunch at runtime from outside Notepad++ by:

  1. Sending SetWindowPlacement with showCmd=SW_SHOWNOACTIVATE and an off-screen rcNormalPosition to ensure WS_VISIBLE is set without making Notepad++ appear on screen
  2. Posting WM_COMMAND with command ID IDM_SYSTRAYPOPUP_CLOSE (43105) — this clears _isPrelaunch, removes the tray icon, and does not issue WM_CLOSE (because the window is now WS_VISIBLE)
  3. Posting WM_SYSCOMMAND with SC_CLOSE — this now correctly honors the user's sta_close setting and routes Notepad++ back to the tray with _isPrelaunch=false
  4. Restoring the original rcNormalPosition

A PowerShell-based companion script implementing this exists. Happy to share if useful for context, but the proper fix is the source change above.

Source: notepad-plus-plus/notepad-plus-plus