27#if wxCHECK_VERSION( 3, 3, 0 )
28#include <wx/msw/darkmode.h>
34#include <versionhelpers.h>
38#if defined( _MSC_VER )
59 __declspec(dllexport)
void NoHotPatch()
67#if wxCHECK_VERSION( 3, 3, 0 )
68class KICAD_DARK_MODE_SETTINGS :
public wxDarkModeSettings
71 wxColour GetColour( wxSystemColour
index )
override
76 case wxSYS_COLOUR_3DLIGHT:
77 return wxColour( 0x2B2B2B );
79 default:
return wxDarkModeSettings::GetColour(
index );
88#if defined( _MSC_VER ) && defined( DEBUG )
91 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
98 SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX );
103 SetDllDirectory( wxT(
"" ) );
106 SetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
110 AttachConsole( wxGetEnv( wxS(
"KICAD_ALLOC_CONSOLE" ),
nullptr ) );
114 bool forceLog = wxGetEnv( wxS(
"KICAD_FORCE_CONSOLE_TRACE" ),
nullptr );
118 wxLog::EnableLogging(
true );
120 wxLog::SetLogLevel( wxLOG_Trace );
122 wxLog::SetActiveTarget(
new wxLogStderr );
131#if wxCHECK_VERSION( 3, 3, 0 )
132 wxTheApp->MSWEnableDarkMode( aForce ? wxApp::DarkMode_Always : wxApp::DarkMode_Auto,
new KICAD_DARK_MODE_SETTINGS() );
139 if( ::AttachConsole( ATTACH_PARENT_PROCESS ) || ( aTryAlloc && ::AllocConsole() ) )
141 #if !defined( __MINGW32__ )
144 if( ::GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE )
146 freopen(
"CONIN$",
"r", stdin );
147 setvbuf( stdin, NULL, _IONBF, 0 );
150 if( ::GetStdHandle( STD_OUTPUT_HANDLE ) != INVALID_HANDLE_VALUE )
152 freopen(
"CONOUT$",
"w", stdout );
153 setvbuf( stdout, NULL, _IONBF, 0 );
156 if( ::GetStdHandle( STD_ERROR_HANDLE ) != INVALID_HANDLE_VALUE )
158 freopen(
"CONOUT$",
"w", stderr );
159 setvbuf( stderr, NULL, _IONBF, 0 );
163 std::ios::sync_with_stdio(
true );
181#if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
182 || PYTHON_VERSION_MAJOR > 3 )
188 return !IsWindows8OrGreater();
198 wxString restartCmd = wxS(
"\"" ) + aCommandLine + wxS(
"\"" );
201 if( restartCmd.length() > RESTART_MAX_CMD_LINE - 1 )
208 hr = ::RegisterApplicationRestart( restartCmd.wc_str(), RESTART_NO_PATCH );
210 return SUCCEEDED( hr );
217 return SUCCEEDED( ::UnregisterApplicationRestart() );
230 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
240 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
242 ShutdownBlockReasonCreate( aWindow->GetHandle(), aReason.wc_str() );
250 PeekMessage( &msg,
nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE );
256 SetDllDirectory( aPath.c_str() );