mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-04 00:47:23 +00:00
[Updated & Fixed] On Console Click
This commit is contained in:
parent
0bf4415376
commit
ace6947255
@ -99,7 +99,7 @@ wxEND_EVENT_TABLE()
|
|||||||
|
|
||||||
/////////// SettingsFrame Event Table ///////////
|
/////////// SettingsFrame Event Table ///////////
|
||||||
wxBEGIN_EVENT_TABLE(MySettingsFrame, wxFrame)
|
wxBEGIN_EVENT_TABLE(MySettingsFrame, wxFrame)
|
||||||
EVT_BUTTON(45, MySettingsFrame::OnClickConsole)
|
EVT_CHECKBOX(45, MySettingsFrame::OnClickConsole)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@ -149,7 +149,8 @@ bool MyApp::OnInit() {
|
|||||||
bool isSignedIn () {
|
bool isSignedIn () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void WindowsConsole () {
|
void WindowsConsole (bool isChecked) {
|
||||||
|
if (isChecked) {
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
FILE* pNewStdout = nullptr;
|
FILE* pNewStdout = nullptr;
|
||||||
FILE* pNewStderr = nullptr;
|
FILE* pNewStderr = nullptr;
|
||||||
@ -158,7 +159,14 @@ void WindowsConsole () {
|
|||||||
::freopen_s(&pNewStdout, "CONOUT$", "w", stdout);
|
::freopen_s(&pNewStdout, "CONOUT$", "w", stdout);
|
||||||
::freopen_s(&pNewStderr, "CONOUT$", "w", stderr);
|
::freopen_s(&pNewStderr, "CONOUT$", "w", stderr);
|
||||||
::freopen_s(&pNewStdin, "CONIN$", "r", stdin);
|
::freopen_s(&pNewStdin, "CONIN$", "r", stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
FreeConsole();
|
||||||
|
::fclose(stdout);
|
||||||
|
::fclose(stderr);
|
||||||
|
::fclose(stdin);
|
||||||
|
}
|
||||||
// Clear the error state for all of the C++ standard streams. Attempting to accessing the streams before they refer
|
// Clear the error state for all of the C++ standard streams. Attempting to accessing the streams before they refer
|
||||||
// to a valid target causes the stream to enter an error state. Clearing the error state will fix this problem,
|
// to a valid target causes the stream to enter an error state. Clearing the error state will fix this problem,
|
||||||
// which seems to occur in newer version of Visual Studio even when the console has not been read from or written
|
// which seems to occur in newer version of Visual Studio even when the console has not been read from or written
|
||||||
@ -458,13 +466,8 @@ void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
|||||||
|
|
||||||
/////////// OnClick Console Event ///////////
|
/////////// OnClick Console Event ///////////
|
||||||
void MySettingsFrame::OnClickConsole(wxCommandEvent& event WXUNUSED(event)) {
|
void MySettingsFrame::OnClickConsole(wxCommandEvent& event WXUNUSED(event)) {
|
||||||
if (checkConsole->IsChecked()) {
|
WindowsConsole(checkConsole->IsChecked());
|
||||||
WindowsConsole();
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
FreeConsole();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////// MAIN FUNCTION ///////////
|
/////////// MAIN FUNCTION ///////////
|
||||||
@ -476,9 +479,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
if (Launcher::EntryThread.joinable()) {
|
if (Launcher::EntryThread.joinable()) {
|
||||||
Launcher::EntryThread.join();
|
Launcher::EntryThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user