MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / toggleConsole

Method toggleConsole

gui/qt/win32-console.cpp:9–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <windows.h>
8
9void MainWindow::toggleConsole() {
10 if (actionToggleConsole->isChecked()) {
11 // If the console is created from opening up the EXE in
12 // Explorer, the console will be completely destroyed once the
13 // console is hidden/freed. Therefore, we need to check for
14 // that, and create a new console if necessary. On the other
15 // hand, if we spawned this process from an existing console,
16 // AttachConsole will still work!
17 if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
18 if (!AllocConsole()) {
19 QMessageBox::critical(this, "Error", "Unable to open console.");
20 }
21 }
22 SetConsoleOutputCP(CP_UTF8);
23 } else {
24 if (!FreeConsole()) {
25 QMessageBox::critical(this, "Error", "Unable to close console. If you are running directly from a console, you may not be able to close it.");
26 }
27 }
28
29 m_config->setValue(SETTING_ENABLE_WIN_CONSOLE, actionToggleConsole->isChecked());
30}
31
32void MainWindow::installToggleConsole() {
33 // Build menu option and add it!

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected