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 );
125#if wxCHECK_VERSION( 3, 3, 0 )
126 wxTheApp->MSWEnableDarkMode( 0,
new KICAD_DARK_MODE_SETTINGS() );
135 if( ::AttachConsole( ATTACH_PARENT_PROCESS ) || ( aTryAlloc && ::AllocConsole() ) )
137 #if !defined( __MINGW32__ )
140 if( ::GetStdHandle( STD_INPUT_HANDLE ) != INVALID_HANDLE_VALUE )
142 freopen(
"CONIN$",
"r", stdin );
143 setvbuf( stdin, NULL, _IONBF, 0 );
146 if( ::GetStdHandle( STD_OUTPUT_HANDLE ) != INVALID_HANDLE_VALUE )
148 freopen(
"CONOUT$",
"w", stdout );
149 setvbuf( stdout, NULL, _IONBF, 0 );
152 if( ::GetStdHandle( STD_ERROR_HANDLE ) != INVALID_HANDLE_VALUE )
154 freopen(
"CONOUT$",
"w", stderr );
155 setvbuf( stderr, NULL, _IONBF, 0 );
159 std::ios::sync_with_stdio(
true );
177#if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \
178 || PYTHON_VERSION_MAJOR > 3 )
184 return !IsWindows8OrGreater();
194 wxString restartCmd = wxS(
"\"" ) + aCommandLine + wxS(
"\"" );
197 if( restartCmd.length() > RESTART_MAX_CMD_LINE - 1 )
204 hr = ::RegisterApplicationRestart( restartCmd.wc_str(), RESTART_NO_PATCH );
206 return SUCCEEDED( hr );
213 return SUCCEEDED( ::UnregisterApplicationRestart() );
226 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
236 ShutdownBlockReasonDestroy( aWindow->GetHandle() );
238 ShutdownBlockReasonCreate( aWindow->GetHandle(), aReason.wc_str() );
246 PeekMessage( &msg,
nullptr, WM_TIMER, WM_TIMER, PM_NOREMOVE );
252 SetDllDirectory( aPath.c_str() );