Skip to content

Commit 8553e28

Browse files
committed
Hide console window only when launched by double-clicking, not from CLI
1 parent ced20df commit 8553e28

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Source/MainWindow.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ MainWindow::MainWindow (const File& fileToLoad, bool isConsoleApp_) : isConsoleA
142142
#ifdef JUCE_WINDOWS
143143
documentWindow->setUsingNativeTitleBar (false);
144144
#ifdef NDEBUG
145-
ShowWindow (GetConsoleWindow(), SW_HIDE);
145+
// Only hide console if launched by double-clicking (not from CLI)
146+
// Check if console is attached to a parent process (CLI) or standalone
147+
DWORD processList[2];
148+
DWORD processCount = GetConsoleProcessList (processList, 2);
149+
150+
// If only 1 process (this app), it was launched by double-clicking
151+
// If more than 1, it was launched from an existing console (CLI)
152+
if (processCount == 1)
153+
{
154+
ShowWindow (GetConsoleWindow(), SW_HIDE);
155+
}
146156
#endif
147157
#else
148158
documentWindow->setUsingNativeTitleBar (true); // Use native title bar on Mac and Linux

0 commit comments

Comments
 (0)