27#if wxCHECK_VERSION( 3, 3, 0 )
28#include <wx/msw/darkmode.h>
34#include <versionhelpers.h>
39#if defined( _MSC_VER )
60 __declspec(dllexport)
void NoHotPatch()
68#if wxCHECK_VERSION( 3, 3, 0 )
69class KICAD_DARK_MODE_SETTINGS :
public wxDarkModeSettings
72 wxColour GetColour( wxSystemColour
index )
override
77 case wxSYS_COLOUR_3DLIGHT:
78 return wxColour( 0x2B2B2B );
80 default:
return wxDarkModeSettings::GetColour(
index );
89#if defined( _MSC_VER ) && defined( DEBUG )
92 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF );
99 SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX );
104 SetDllDirectory( wxT(
"" ) );
107 SetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
111 AttachConsole( wxGetEnv( wxS(
"KICAD_ALLOC_CONSOLE" ),
nullptr ) );
115 bool forceLog = wxGetEnv( wxS(
"KICAD_FORCE_CONSOLE_TRACE" ),
nullptr );
119 wxLog::EnableLogging(
true );
121 wxLog::SetLogLevel( wxLOG_Trace );
123 const int fd = _fileno( stderr );
124 wxLog::SetActiveTarget( fd >= 0 && !_isatty( fd ) ?
new wxLogStderr( stderr, wxConvUTF8 )
134#if wxCHECK_VERSION( 3, 3, 0 )
135 wxTheApp->MSWEnableDarkMode( aForce ? wxApp::DarkMode_Always : wxApp::DarkMode_Auto,
new KICAD_DARK_MODE_SETTINGS() );
142 if( ::AttachConsole( ATTACH_PARENT_PROCESS ) || ( aTryAlloc && ::AllocConsole() ) )
144 #if !defined( __MINGW32__ )
147 if( ::GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE )
149 freopen(
"CONIN$",
"r", stdin );
150 setvbuf( stdin, NULL, _IONBF, 0 );
153 if( ::GetStdHandle( STD_OUTPUT_HANDLE ) != INVALID_HANDLE_VALUE )
155 freopen(
"CONOUT$",
"w", stdout );
156 setvbuf( stdout, NULL, _IONBF, 0 );
159 if( ::GetStdHandle( STD_ERROR_HANDLE ) != INVALID_HANDLE_VALUE )
161 freopen(
"CONOUT$",
"w", stderr );
162 setvbuf( stderr, NULL, _IONBF, 0 );
166 std::ios::sync_with_stdio(
true );
184#if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
185 || PYTHON_VERSION_MAJOR > 3 )
191 return !IsWindows8OrGreater();
201 wxString restartCmd = wxS(
"\"" ) + aCommandLine + wxS(
"\"" );
204 if( restartCmd.length() > RESTART_MAX_CMD_LINE - 1 )
211 hr = ::RegisterApplicationRestart( restartCmd.wc_str(), RESTART_NO_PATCH );
213 return SUCCEEDED( hr );
220 return SUCCEEDED( ::UnregisterApplicationRestart() );
233 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
243 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
245 ShutdownBlockReasonCreate( aWindow->GetHandle(), aReason.wc_str() );
253 PeekMessage( &msg,
nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE );
259 SetDllDirectory( aPath.c_str() );