diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp
index bb7b4f1896..b750af6f0b 100644
--- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp
+++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp
@@ -52,6 +52,7 @@
 #include <tool/action_toolbar.h>
 #include <widgets/infobar.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/filedlg.h>
 
 /**
  * Flag to enable 3D viewer main frame window debug tracing.
diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp
index f1893df35a..12eafa8144 100644
--- a/bitmap2component/bitmap2cmp_gui.cpp
+++ b/bitmap2component/bitmap2cmp_gui.cpp
@@ -35,6 +35,11 @@
 #include <wildcards_and_files_ext.h>
 #include <wx/clipbrd.h>
 #include <wx/rawbmp.h>
+#include <wx/filedlg.h>
+#include <wx/rawbmp.h>
+#include <wx/msgdlg.h>
+#include <wx/dcclient.h>
+
 
 #include "bitmap2cmp_gui_base.h"
 
diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp
index f69f1b0ad3..dc0bcb3626 100644
--- a/common/dialogs/dialog_page_settings.cpp
+++ b/common/dialogs/dialog_page_settings.cpp
@@ -36,6 +36,8 @@
 #include <drawing_sheet/ds_painter.h>
 #include <wx/valgen.h>
 #include <wx/tokenzr.h>
+#include <wx/filedlg.h>
+#include <wx/dcmemory.h>
 
 #define MAX_PAGE_EXAMPLE_SIZE 200
 
diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp
index 0f6321aa68..bcf6716816 100644
--- a/common/eda_draw_frame.cpp
+++ b/common/eda_draw_frame.cpp
@@ -59,6 +59,9 @@
 #include <wx/snglinst.h>
 #include <dialogs/dialog_grid_settings.h>
 #include <widgets/ui_common.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
+#include <wx/msgdlg.h>
 
 #define FR_HISTORY_LIST_CNT     10   ///< Maximum size of the find/replace history stacks.
 
diff --git a/common/kiway_express.cpp b/common/kiway_express.cpp
index 72418fc917..38c7485d0a 100644
--- a/common/kiway_express.cpp
+++ b/common/kiway_express.cpp
@@ -23,6 +23,8 @@
  */
 
 #include <kiway_express.h>
+#include <wx/wx.h>
+
 
 //IMPLEMENT_DYNAMIC_CLASS( KIWAY_EXPRESS, wxEvent )
 
diff --git a/common/project/project_archiver.cpp b/common/project/project_archiver.cpp
index 657def6624..a84246d2bd 100644
--- a/common/project/project_archiver.cpp
+++ b/common/project/project_archiver.cpp
@@ -29,6 +29,7 @@
 #include <project/project_archiver.h>
 #include <reporter.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/log.h>
 
 
 #define ZipFileExtension wxT( "zip" )
diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp
index 004bb0cb92..ec1fd7ca3b 100644
--- a/common/tool/action_toolbar.cpp
+++ b/common/tool/action_toolbar.cpp
@@ -42,6 +42,7 @@
 #include <wx/popupwin.h>
 #include <wx/renderer.h>
 #include <wx/sizer.h>
+#include <wx/dcclient.h>
 
 
 wxBitmap MakeDisabledBitmap( const wxBitmap& aSource )
diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp
index 0f88ec37f7..ea77207dff 100644
--- a/common/tool/common_control.cpp
+++ b/common/tool/common_control.cpp
@@ -38,6 +38,7 @@
 #include <kicad_curl/kicad_curl_easy.h>
 #include <dialogs/dialog_configure_paths.h>
 #include <eda_doc.h>
+#include <wx/msgdlg.h>
 
 #define URL_GET_INVOLVED "https://kicad.org/contribute/"
 #define URL_DONATE "https://go.kicad.org/app-donate"
diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp
index cb4dbad49d..d4fe201da0 100644
--- a/common/tool/tool_dispatcher.cpp
+++ b/common/tool/tool_dispatcher.cpp
@@ -43,6 +43,8 @@
 #include <wx/stc/stc.h>
 #include <kiplatform/app.h>
 
+#include <wx/wx.h>      // for GetForegroundWindow() on wxMSW
+
 ///< Stores information about a mouse button state
 struct TOOL_DISPATCHER::BUTTON_STATE
 {
diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp
index 09afa2aec0..21c548daf2 100644
--- a/common/view/wx_view_controls.cpp
+++ b/common/view/wx_view_controls.cpp
@@ -38,6 +38,8 @@
 #include <widgets/ui_common.h>
 #include <class_draw_panel_gal.h>
 
+#include <wx/wx.h>      // for GetForegroundWindow() on wxMSW
+
 #if defined __WXMSW__
     #define USE_MOUSE_CAPTURE
 #endif
diff --git a/common/widgets/infobar.cpp b/common/widgets/infobar.cpp
index 1a110ca66f..c55d75359b 100644
--- a/common/widgets/infobar.cpp
+++ b/common/widgets/infobar.cpp
@@ -28,6 +28,7 @@
 #include <wx/sizer.h>
 #include <wx/timer.h>
 #include <wx/hyperlink.h>
+#include <wx/bmpbuttn.h>
 #include <eda_base_frame.h>
 
 
diff --git a/common/widgets/net_selector.cpp b/common/widgets/net_selector.cpp
index aa61946b85..31fa884758 100644
--- a/common/widgets/net_selector.cpp
+++ b/common/widgets/net_selector.cpp
@@ -30,6 +30,12 @@
 #include <netinfo.h>
 #include <wx/arrstr.h>
 #include <wx/display.h>
+#include <wx/valtext.h>
+#include <wx/listbox.h>
+#include <wx/stattext.h>
+#include <wx/sizer.h>
+#include <wx/textctrl.h>
+
 
 wxDEFINE_EVENT( NET_SELECTED, wxCommandEvent );
 
diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp
index 0a9a1c6d2a..6faa21ff61 100644
--- a/common/wildcards_and_files_ext.cpp
+++ b/common/wildcards_and_files_ext.cpp
@@ -30,6 +30,8 @@
 #include <regex>
 #include <wildcards_and_files_ext.h>
 #include <wx/regex.h>
+#include <wx/wx.h>
+
 
 bool compareFileExtensions( const std::string& aExtension,
         const std::vector<std::string>& aReference, bool aCaseSensitive )
diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp
index 34c40fa963..439ec9fb49 100644
--- a/cvpcb/cvpcb_mainframe.cpp
+++ b/cvpcb/cvpcb_mainframe.cpp
@@ -52,6 +52,7 @@
 #include <tools/cvpcb_actions.h>
 #include <tools/cvpcb_association_tool.h>
 #include <tools/cvpcb_control.h>
+#include <wx/button.h>
 
 #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
 
diff --git a/cvpcb/dialogs/dialog_config_equfiles.cpp b/cvpcb/dialogs/dialog_config_equfiles.cpp
index ed110adb24..562618b437 100644
--- a/cvpcb/dialogs/dialog_config_equfiles.cpp
+++ b/cvpcb/dialogs/dialog_config_equfiles.cpp
@@ -39,6 +39,8 @@
 #include <settings/settings_manager.h>
 #include <wildcards_and_files_ext.h>
 
+#include <wx/filedlg.h>
+
 
 DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
     DIALOG_CONFIG_EQUFILES_BASE( aParent )
diff --git a/cvpcb/listbox_base.cpp b/cvpcb/listbox_base.cpp
index a253387c78..cf28338471 100644
--- a/cvpcb/listbox_base.cpp
+++ b/cvpcb/listbox_base.cpp
@@ -28,6 +28,7 @@
 
 #include <cvpcb_mainframe.h>
 #include <listboxes.h>
+#include <wx/dcclient.h>
 
 
 /******************************************************************************
diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp
index 9a8599866e..dcd4956423 100644
--- a/eeschema/dialogs/dialog_fields_editor_global.cpp
+++ b/eeschema/dialogs/dialog_fields_editor_global.cpp
@@ -42,6 +42,7 @@
 #include <widgets/wx_grid.h>
 #include <wx/grid.h>
 #include <wx/msgdlg.h>
+#include <wx/textdlg.h>
 
 #include "dialog_fields_editor_global.h"
 
diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp
index 9d29ef7e9d..d163cc2911 100644
--- a/eeschema/dialogs/dialog_netlist.cpp
+++ b/eeschema/dialogs/dialog_netlist.cpp
@@ -49,6 +49,9 @@
 
 #include <eeschema_id.h>
 #include <wx/regex.h>
+#include <wx/filedlg.h>
+#include <wx/msgdlg.h>
+
 
 
 #define CUSTOMPANEL_COUNTMAX 8  // Max number of netlist plugins
diff --git a/eeschema/dialogs/dialog_sch_import_settings.cpp b/eeschema/dialogs/dialog_sch_import_settings.cpp
index 018611c0d3..b4b6164297 100644
--- a/eeschema/dialogs/dialog_sch_import_settings.cpp
+++ b/eeschema/dialogs/dialog_sch_import_settings.cpp
@@ -26,6 +26,7 @@
 #include <wildcards_and_files_ext.h>
 #include <confirm.h>
 #include <schematic.h>
+#include <wx/filedlg.h>
 
 #include <dialog_sch_import_settings.h>
 
diff --git a/eeschema/dialogs/dialog_spice_model.cpp b/eeschema/dialogs/dialog_spice_model.cpp
index 006a0e2f1a..4222e4a19f 100644
--- a/eeschema/dialogs/dialog_spice_model.cpp
+++ b/eeschema/dialogs/dialog_spice_model.cpp
@@ -33,6 +33,8 @@
 #include <wx/textfile.h>
 #include <wx/tokenzr.h>
 #include <wx/wupdlock.h>
+#include <wx/filedlg.h>
+
 
 #include <cctype>
 #include <cstring>
diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp
index 7613441da9..9c2c0ed472 100644
--- a/eeschema/dialogs/panel_sym_lib_table.cpp
+++ b/eeschema/dialogs/panel_sym_lib_table.cpp
@@ -46,6 +46,8 @@
 #include <widgets/grid_readonly_text_helpers.h>
 #include <widgets/grid_text_button_helpers.h>
 #include <sch_file_versions.h>
+#include <wx/filedlg.h>
+
 
 
 // clang-format off
diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp
index 23f9762c6f..85685c458a 100644
--- a/eeschema/sch_edit_frame.cpp
+++ b/eeschema/sch_edit_frame.cpp
@@ -77,6 +77,9 @@
 #include <widgets/infobar.h>
 #include <wildcards_and_files_ext.h>
 #include <wx/cmdline.h>
+#include <wx/app.h>
+#include <wx/filedlg.h>
+
 #include <gal/graphics_abstraction_layer.h>
 #include <drawing_sheet/ds_proxy_view_item.h>
 
diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp
index 49026a3180..4d3c64a955 100644
--- a/eeschema/sheet.cpp
+++ b/eeschema/sheet.cpp
@@ -28,7 +28,6 @@
 #include <project.h>
 #include <wildcards_and_files_ext.h>
 #include <tool/tool_manager.h>
-#include <wx/clipbrd.h>
 #include <sch_edit_frame.h>
 #include <sch_plugins/legacy/sch_legacy_plugin.h>
 #include <sch_sheet.h>
@@ -40,6 +39,9 @@
 #include <dialogs/dialog_sheet_properties.h>
 #include <tool/actions.h>
 
+#include <wx/clipbrd.h>
+#include <wx/dcmemory.h>
+
 
 bool SCH_EDIT_FRAME::CheckSheetForRecursion( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
 {
diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp
index 8b21b26e7f..258f316aeb 100644
--- a/eeschema/sim/sim_plot_frame.cpp
+++ b/eeschema/sim/sim_plot_frame.cpp
@@ -48,6 +48,7 @@
 #include <tools/ee_actions.h>
 #include <eeschema_settings.h>
 #include <wx/ffile.h>
+#include <wx/filedlg.h>
 #include <dialog_shim.h>
 
 SIM_PLOT_TYPE operator|( SIM_PLOT_TYPE aFirst, SIM_PLOT_TYPE aSecond )
diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp
index c6a8a48378..ea2117970d 100644
--- a/eeschema/symbol_editor/symbol_edit_frame.cpp
+++ b/eeschema/symbol_editor/symbol_edit_frame.cpp
@@ -71,6 +71,7 @@
 #include <widgets/symbol_tree_pane.h>
 #include <wildcards_and_files_ext.h>
 #include <panel_sym_lib_table.h>
+#include <wx/choicdlg.h>
 
 
 bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false;
diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp
index 9790a3ddeb..2dd368684c 100644
--- a/eeschema/symbol_editor/symbol_editor.cpp
+++ b/eeschema/symbol_editor/symbol_editor.cpp
@@ -42,6 +42,8 @@
 #include <dialogs/dialog_lib_new_component.h>
 #include <dialog_helpers.h>
 #include <wx/clipbrd.h>
+#include <wx/filedlg.h>
+
 
 
 /**
diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp
index 4dc0e3d963..c65df2150c 100644
--- a/eeschema/symbol_editor/symbol_editor_import_export.cpp
+++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp
@@ -30,6 +30,7 @@
 #include <wildcards_and_files_ext.h>
 #include <symbol_library_manager.h>
 #include <wx/filename.h>
+#include <wx/filedlg.h>
 
 
 void SYMBOL_EDIT_FRAME::ImportPart()
diff --git a/eeschema/tools/assign_footprints.cpp b/eeschema/tools/assign_footprints.cpp
index 20816686a4..a2e2e6d5c0 100644
--- a/eeschema/tools/assign_footprints.cpp
+++ b/eeschema/tools/assign_footprints.cpp
@@ -35,9 +35,11 @@
 #include <dsnlexer.h>
 #include <ptree.h>
 #include <boost/property_tree/ptree.hpp>
-#include <wx/choicdlg.h>
 #include <tools/sch_editor_control.h>
 
+#include <wx/choicdlg.h>
+#include <wx/filedlg.h>
+
 
 void SCH_EDITOR_CONTROL::AssignFootprints( const std::string& aChangedSetOfReferences )
 {
diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp
index 81004bd466..c98a3ad9b5 100644
--- a/eeschema/tools/sch_drawing_tools.cpp
+++ b/eeschema/tools/sch_drawing_tools.cpp
@@ -52,6 +52,8 @@
 #include <dialogs/dialog_sheet_pin_properties.h>
 #include <kicad_string.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/filedlg.h>
+
 
 SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
         EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp
index 5ac7501e55..57059e3ab0 100644
--- a/eeschema/tools/sch_edit_tool.cpp
+++ b/eeschema/tools/sch_edit_tool.cpp
@@ -66,6 +66,9 @@
 #include <symbol_editor_settings.h>
 #include <dialogs/dialog_edit_label.h>
 #include <core/kicad_algo.h>
+//#include <wx/filedlg.h>
+#include <wx/textdlg.h>
+
 
 
 class SYMBOL_UNIT_MENU : public ACTION_MENU
diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp
index 82344bcf97..2aa0ad15c1 100644
--- a/eeschema/tools/symbol_editor_control.cpp
+++ b/eeschema/tools/symbol_editor_control.cpp
@@ -35,6 +35,7 @@
 #include <gestfich.h>
 #include <bitmaps/bitmap_types.h>
 #include <confirm.h>
+#include <wx/filedlg.h>
 
 
 bool SYMBOL_EDITOR_CONTROL::Init()
diff --git a/gerbview/dialogs/dialog_print_gerbview.cpp b/gerbview/dialogs/dialog_print_gerbview.cpp
index 68cef383b6..119c388748 100644
--- a/gerbview/dialogs/dialog_print_gerbview.cpp
+++ b/gerbview/dialogs/dialog_print_gerbview.cpp
@@ -35,6 +35,7 @@
 #include <tool/tool_manager.h>
 #include <tools/gerbview_actions.h>
 #include <tools/gerbview_control.h>
+#include <wx/checklst.h>
 
 // TODO(JE)
 #define OPTKEY_LAYERBASE             wxT( "PlotLayer_%d" )
diff --git a/gerbview/job_file_reader.cpp b/gerbview/job_file_reader.cpp
index f1f56c62df..bc2e902f78 100644
--- a/gerbview/job_file_reader.cpp
+++ b/gerbview/job_file_reader.cpp
@@ -41,6 +41,8 @@
 #include <gbr_metadata.h>
 #include <dialogs/html_messagebox.h>
 #include <view/view.h>
+#include <wx/filedlg.h>
+
 
 using json = nlohmann::json;
 
diff --git a/gerbview/tools/gerbview_control.cpp b/gerbview/tools/gerbview_control.cpp
index ec66bdf569..cc512e1acb 100644
--- a/gerbview/tools/gerbview_control.cpp
+++ b/gerbview/tools/gerbview_control.cpp
@@ -31,6 +31,7 @@
 #include <tool/tool_manager.h>
 #include <view/view.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/filedlg.h>
 
 #include "gerbview_actions.h"
 #include "gerbview_control.h"
diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp
index 66848bf653..981bf86479 100644
--- a/gerbview/tools/gerbview_inspection_tool.cpp
+++ b/gerbview/tools/gerbview_inspection_tool.cpp
@@ -36,7 +36,9 @@
 #include <view/view.h>
 #include <view/view_controls.h>
 #include <view/view_group.h>
-
+#include <wx/msgdlg.h>
+#include <wx/textdlg.h>
+#include <wx/choicdlg.h>
 
 
 GERBVIEW_INSPECTION_TOOL::GERBVIEW_INSPECTION_TOOL() :
diff --git a/include/eda_pattern_match.h b/include/eda_pattern_match.h
index bd08b362cf..d543279cbd 100644
--- a/include/eda_pattern_match.h
+++ b/include/eda_pattern_match.h
@@ -32,7 +32,6 @@
 #include <vector>
 #include <map>
 #include <memory>
-#include <wx/wx.h>
 #include <wx/string.h>
 #include <wx/regex.h>
 
diff --git a/include/kiway_express.h b/include/kiway_express.h
index cc18bc8aec..7bd69cab74 100644
--- a/include/kiway_express.h
+++ b/include/kiway_express.h
@@ -26,10 +26,10 @@
 #define KIWAY_EXPRESS_H_
 
 // @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
-
-#include <wx/wx.h>
 #include <frame_type.h>
 #include <mail_type.h>
+#include <wx/string.h>
+#include <wx/event.h>
 
 
 /**
diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h
index 1a9868f781..4074850dc3 100644
--- a/include/tool/conditional_menu.h
+++ b/include/tool/conditional_menu.h
@@ -30,7 +30,6 @@
 #include <tool/selection_conditions.h>
 #include <tool/action_menu.h>
 #include <list>
-#include <wx/wx.h>
 
 class PCB_SELECTION_TOOL;
 class TOOL_ACTION;
diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h
index 4e73f0872b..d4c0760762 100644
--- a/include/view/wx_view_controls.h
+++ b/include/view/wx_view_controls.h
@@ -33,11 +33,10 @@
 #ifndef __WX_VIEW_CONTROLS_H
 #define __WX_VIEW_CONTROLS_H
 
-#include <wx/wx.h>
-
 #include <view/view_controls.h>
-
+#include <wx/timer.h>
 #include <memory>
+
 class EDA_DRAW_PANEL_GAL;
 
 namespace KIGFX
diff --git a/include/widgets/infobar.h b/include/widgets/infobar.h
index ba3265fe89..9f92aa8f92 100644
--- a/include/widgets/infobar.h
+++ b/include/widgets/infobar.h
@@ -24,7 +24,9 @@
 #include <core/optional.h>
 #include <wx/event.h>
 #include <wx/infobar.h>
-#include <wx/wx.h>
+#include <wx/timer.h>
+#include <wx/panel.h>
+#include <wx/sizer.h>
 
 
 class wxAuiManager;
diff --git a/include/widgets/net_selector.h b/include/widgets/net_selector.h
index db079e6638..b3a789b538 100644
--- a/include/widgets/net_selector.h
+++ b/include/widgets/net_selector.h
@@ -24,7 +24,6 @@
 #ifndef __WIDGET_NET_SELECTOR_H
 #define __WIDGET_NET_SELECTOR_H
 
-#include <wx/wx.h>
 #include <wx/combo.h>
 
 
diff --git a/include/widgets/number_badge.h b/include/widgets/number_badge.h
index 2b433f1fa3..a193fb433b 100644
--- a/include/widgets/number_badge.h
+++ b/include/widgets/number_badge.h
@@ -25,7 +25,9 @@
 #define NUMBER_BADGE_H_
 
 #include <widgets/ui_common.h>
-#include <wx/wx.h>
+#include <wx/dcclient.h>
+#include <wx/panel.h>
+
 
 /**
  * A simple UI element that puts a number on top of a colored rounded rectangle with a fill
diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h
index f2b71859d5..949666fec7 100644
--- a/include/wildcards_and_files_ext.h
+++ b/include/wildcards_and_files_ext.h
@@ -32,10 +32,9 @@
 #ifndef INCLUDE_WILDCARDS_AND_FILES_EXT_H_
 #define INCLUDE_WILDCARDS_AND_FILES_EXT_H_
 
-#include <wx/wx.h>
-
 #include <string>
 #include <vector>
+#include <wx/string.h>
 
 /**
  * \defgroup file_extensions File Extension Definitions
diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp
index 8930afaf51..82974555d0 100644
--- a/kicad/files-io.cpp
+++ b/kicad/files-io.cpp
@@ -27,6 +27,8 @@
  */
 
 #include <wx/dir.h>
+#include <wx/filedlg.h>
+#include <wx/dirdlg.h>
 
 #include <confirm.h>
 #include <dialogs/panel_kicad_launcher.h>
diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp
index d927dcf0e2..4a432f512e 100644
--- a/kicad/import_project.cpp
+++ b/kicad/import_project.cpp
@@ -32,6 +32,8 @@
 #include <wx/filefn.h>
 #include <wx/filename.h>
 #include <wx/dir.h>
+#include <wx/filedlg.h>
+#include <wx/dirdlg.h>
 
 #include <common.h>
 #include <confirm.h>
diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp
index 197940a704..c266a95127 100644
--- a/kicad/project_tree_pane.cpp
+++ b/kicad/project_tree_pane.cpp
@@ -28,6 +28,8 @@
 #include <wx/regex.h>
 #include <wx/stdpaths.h>
 #include <wx/string.h>
+#include <wx/msgdlg.h>
+#include <wx/textdlg.h>
 
 #include <bitmaps.h>
 #include <common.h>
diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp
index a37adb5ef1..f7b926dd77 100644
--- a/kicad/tools/kicad_manager_control.cpp
+++ b/kicad/tools/kicad_manager_control.cpp
@@ -31,6 +31,7 @@
 #include <dialogs/dialog_template_selector.h>
 #include <gestfich.h>
 #include <wx/dir.h>
+#include <wx/filedlg.h>
 
 
 ///< Helper widget to select whether a new directory should be created for a project.
diff --git a/pagelayout_editor/files.cpp b/pagelayout_editor/files.cpp
index 9f48b8fde5..fca8ce31aa 100644
--- a/pagelayout_editor/files.cpp
+++ b/pagelayout_editor/files.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2013 CERN
- * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  *
@@ -35,6 +35,8 @@
 #include "pl_editor_id.h"
 #include "properties_frame.h"
 
+#include <wx/filedlg.h>
+
 bool PL_EDITOR_FRAME::saveCurrentPageLayout()
 {
     wxCommandEvent saveEvent;
diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp
index 3f15a2d047..964d30f9b7 100644
--- a/pcbnew/build_BOM_from_board.cpp
+++ b/pcbnew/build_BOM_from_board.cpp
@@ -33,6 +33,8 @@
 #include <wildcards_and_files_ext.h>
 #include <footprint.h>
 #include <wx/listimpl.cpp>
+#include <wx/filedlg.h>
+
 
 /* creates a BOM list from board
  *  The format is:
diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp
index c49ef96c3c..b07e43c502 100644
--- a/pcbnew/dialogs/dialog_board_statistics.cpp
+++ b/pcbnew/dialogs/dialog_board_statistics.cpp
@@ -27,6 +27,7 @@
 #include "base_units.h"
 #include <macros.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/filedlg.h>
 
 #define COL_LABEL 0
 #define COL_AMOUNT 1
diff --git a/pcbnew/dialogs/dialog_cleanup_graphics.cpp b/pcbnew/dialogs/dialog_cleanup_graphics.cpp
index 6c37b2148b..a842768f41 100644
--- a/pcbnew/dialogs/dialog_cleanup_graphics.cpp
+++ b/pcbnew/dialogs/dialog_cleanup_graphics.cpp
@@ -21,7 +21,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
-#include <wx/wx.h>
 #include <dialog_cleanup_graphics.h>
 #include <tool/tool_manager.h>
 #include <tools/pcb_actions.h>
diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp
index 22917826c2..d551288eab 100644
--- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp
+++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias.cpp
@@ -21,7 +21,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
-#include <wx/wx.h>
 #include <dialog_cleanup_tracks_and_vias.h>
 #include <pcb_edit_frame.h>
 #include <pcbnew_settings.h>
diff --git a/pcbnew/dialogs/dialog_footprint_checker.cpp b/pcbnew/dialogs/dialog_footprint_checker.cpp
index 42f1b7f62b..6f8f98ca19 100644
--- a/pcbnew/dialogs/dialog_footprint_checker.cpp
+++ b/pcbnew/dialogs/dialog_footprint_checker.cpp
@@ -21,7 +21,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
-#include <wx/wx.h>
 #include <dialog_footprint_checker.h>
 #include <widgets/appearance_controls.h>
 #include <tool/tool_manager.h>
diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp
index 158af31304..9bbc9bc232 100644
--- a/pcbnew/dialogs/dialog_gendrill.cpp
+++ b/pcbnew/dialogs/dialog_gendrill.cpp
@@ -39,7 +39,9 @@
 #include <wildcards_and_files_ext.h>
 #include <reporter.h>
 #include <wx/stdpaths.h>
-
+#include <wx/msgdlg.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
 
 // list of allowed precision for EXCELLON files, for integer format:
 // Due to difference between inches and mm,
diff --git a/pcbnew/dialogs/dialog_import_settings.cpp b/pcbnew/dialogs/dialog_import_settings.cpp
index aab4ea8130..435904a01f 100644
--- a/pcbnew/dialogs/dialog_import_settings.cpp
+++ b/pcbnew/dialogs/dialog_import_settings.cpp
@@ -26,6 +26,7 @@
 #include <board.h>
 #include <wildcards_and_files_ext.h>
 #include <confirm.h>
+#include <wx/filedlg.h>
 
 #include <dialog_import_settings.h>
 
diff --git a/pcbnew/dialogs/dialog_net_inspector.cpp b/pcbnew/dialogs/dialog_net_inspector.cpp
index 7dac806e82..68fcd59c0e 100644
--- a/pcbnew/dialogs/dialog_net_inspector.cpp
+++ b/pcbnew/dialogs/dialog_net_inspector.cpp
@@ -38,7 +38,11 @@
 #include <dialogs/dialog_text_entry.h>
 #include <validators.h>
 #include <bitmaps.h>
+
 #include <wx/tokenzr.h>
+#include <wx/filedlg.h>
+#include <wx/dcclient.h>
+
 #include <bitset>
 
 struct DIALOG_NET_INSPECTOR::COLUMN_DESC
diff --git a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp
index 918101f3a6..03354e3600 100644
--- a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp
+++ b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp
@@ -39,6 +39,8 @@
 
 #include <dialog_pad_properties.h>
 #include <bitmaps.h>
+#include <wx/dcclient.h>
+
 
 DIALOG_PAD_PRIMITIVES_PROPERTIES::DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent,
                                                                     PCB_BASE_FRAME* aFrame,
diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp
index a448e4948b..27aa549312 100644
--- a/pcbnew/dialogs/dialog_pad_properties.cpp
+++ b/pcbnew/dialogs/dialog_pad_properties.cpp
@@ -47,6 +47,7 @@
 #include <tool/tool_manager.h>
 #include <tools/pad_tool.h>
 #include <advanced_config.h>    // for pad property feature management
+#include <wx/choicdlg.h>
 
 
 // list of pad shapes, ordered like the pad shape wxChoice in dialog.
diff --git a/pcbnew/dialogs/dialog_print_pcbnew.cpp b/pcbnew/dialogs/dialog_print_pcbnew.cpp
index 6e061484a0..8d4a6dc82e 100644
--- a/pcbnew/dialogs/dialog_print_pcbnew.cpp
+++ b/pcbnew/dialogs/dialog_print_pcbnew.cpp
@@ -37,6 +37,8 @@
 #include <tools/pcb_control.h>
 #include <dialogs/dialog_print_generic.h>
 #include <pcbnew_printout.h>
+#include <wx/checklst.h>
+#include <wx/textdlg.h>
 
 
 class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_GENERIC
diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp
index a98e2cea1d..60f3bc7800 100644
--- a/pcbnew/dialogs/panel_fp_lib_table.cpp
+++ b/pcbnew/dialogs/panel_fp_lib_table.cpp
@@ -35,6 +35,8 @@
 #include <wx/dir.h>
 #include <wx/regex.h>
 #include <wx/grid.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
 
 #include <project.h>
 #include <3d_viewer/eda_3d_viewer.h>      // for KICAD6_3DMODEL_DIR
diff --git a/pcbnew/exporters/export_d356.cpp b/pcbnew/exporters/export_d356.cpp
index a4ce342c89..273a1c075c 100644
--- a/pcbnew/exporters/export_d356.cpp
+++ b/pcbnew/exporters/export_d356.cpp
@@ -44,6 +44,7 @@
 #include <cctype>
 #include <math/util.h>      // for KiROUND
 #include <export_d356.h>
+#include <wx/filedlg.h>
 
 
 
diff --git a/pcbnew/exporters/export_footprint_associations.cpp b/pcbnew/exporters/export_footprint_associations.cpp
index afaa54c351..4b338bf296 100644
--- a/pcbnew/exporters/export_footprint_associations.cpp
+++ b/pcbnew/exporters/export_footprint_associations.cpp
@@ -29,6 +29,8 @@
 #include <footprint.h>
 #include <project.h>
 #include <wildcards_and_files_ext.h>
+#include <wx/filedlg.h>
+
 
 
 bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp
index a45d37dde4..361a094cbd 100644
--- a/pcbnew/exporters/export_gencad.cpp
+++ b/pcbnew/exporters/export_gencad.cpp
@@ -46,6 +46,7 @@
 #include <project/project_file.h> // LAST_PATH_TYPE
 
 #include <wx/app.h>
+#include <wx/filedlg.h>
 
 static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* frame );
 static void CreateArtworksSection( FILE* aFile );
diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp
index e559a771b1..3fd5381eb0 100644
--- a/pcbnew/files.cpp
+++ b/pcbnew/files.cpp
@@ -47,7 +47,6 @@
 #include <kiplatform/app.h>
 #include <widgets/appearance_controls.h>
 #include <widgets/infobar.h>
-#include <wx/wupdlock.h>
 #include <settings/settings_manager.h>
 #include <paths.h>
 #include <project/project_file.h>
@@ -58,6 +57,10 @@
 #include <dialogs/dialog_imported_layers.h>
 #include "footprint_info_impl.h"
 
+#include <wx/wupdlock.h>
+#include <wx/filedlg.h>
+
+
 
 //#define     USE_INSTRUMENTATION     1
 #define     USE_INSTRUMENTATION     0
diff --git a/pcbnew/import_gfx/dialog_import_gfx.cpp b/pcbnew/import_gfx/dialog_import_gfx.cpp
index c610ae92a6..a9cd125c57 100644
--- a/pcbnew/import_gfx/dialog_import_gfx.cpp
+++ b/pcbnew/import_gfx/dialog_import_gfx.cpp
@@ -33,6 +33,7 @@
 #include <bitmaps.h>
 #include <map>
 #include "dxf_import_plugin.h"
+#include <wx/filedlg.h>
 
 #include <memory>
 
diff --git a/pcbnew/import_gfx/dxf_import_plugin.h b/pcbnew/import_gfx/dxf_import_plugin.h
index 352ccb39b4..49d342cb0e 100644
--- a/pcbnew/import_gfx/dxf_import_plugin.h
+++ b/pcbnew/import_gfx/dxf_import_plugin.h
@@ -32,7 +32,6 @@
 #include <dl_dxf.h>
 #include <math/vector3.h>
 #include <wildcards_and_files_ext.h>
-#include <wx/wx.h>
 
 #include <list>
 
diff --git a/pcbnew/microwave/microwave_inductor.cpp b/pcbnew/microwave/microwave_inductor.cpp
index 2adabcb535..21fdff59c3 100644
--- a/pcbnew/microwave/microwave_inductor.cpp
+++ b/pcbnew/microwave/microwave_inductor.cpp
@@ -21,8 +21,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
-#include <wx/wx.h>
-
 #include <base_units.h>
 #include <board_commit.h>
 #include <pad.h>
diff --git a/pcbnew/netlist_reader/kicad_netlist_reader.cpp b/pcbnew/netlist_reader/kicad_netlist_reader.cpp
index 4e8b231260..faed14ce86 100644
--- a/pcbnew/netlist_reader/kicad_netlist_reader.cpp
+++ b/pcbnew/netlist_reader/kicad_netlist_reader.cpp
@@ -25,7 +25,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
-#include <wx/wx.h>
 #include <netlist_lexer.h>  // netlist_lexer is common to Eeschema and Pcbnew
 #include <macros.h>
 
diff --git a/pcbnew/swig/pcbnew_scripting_helpers.cpp b/pcbnew/swig/pcbnew_scripting_helpers.cpp
index 17c37c5530..77052059f8 100644
--- a/pcbnew/swig/pcbnew_scripting_helpers.cpp
+++ b/pcbnew/swig/pcbnew_scripting_helpers.cpp
@@ -46,6 +46,7 @@
 #include <project/project_local_settings.h>
 #include <wildcards_and_files_ext.h>
 #include <locale_io.h>
+#include <wx/app.h>
 
 
 static PCB_EDIT_FRAME* s_PcbEditFrame = NULL;
diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp
index 3bb238c055..b703908716 100644
--- a/pcbnew/toolbars_pcb_editor.cpp
+++ b/pcbnew/toolbars_pcb_editor.cpp
@@ -46,6 +46,7 @@
 #include <tools/pcb_actions.h>
 #include <tools/pcb_selection_tool.h>
 #include <wx/wupdlock.h>
+#include <wx/dcmemory.h>
 
 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
 #include <python_scripting.h>
diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp
index 1e4c2f9cf4..8b71603ff2 100644
--- a/pcbnew/tools/board_editor_control.cpp
+++ b/pcbnew/tools/board_editor_control.cpp
@@ -65,6 +65,7 @@
 #include <wildcards_and_files_ext.h>
 #include <drawing_sheet/ds_proxy_undo_item.h>
 #include <footprint_edit_frame.h>
+#include <wx/filedlg.h>
 
 using namespace std::placeholders;
 
diff --git a/pcbnew/tools/board_reannotate_tool.cpp b/pcbnew/tools/board_reannotate_tool.cpp
index 6bc3568000..ffe139e4a8 100644
--- a/pcbnew/tools/board_reannotate_tool.cpp
+++ b/pcbnew/tools/board_reannotate_tool.cpp
@@ -25,7 +25,6 @@
 
 #include <tool/tool_manager.h>
 #include <wx/filedlg.h>
-#include <wx/wx.h>
 #include <tools/board_reannotate_tool.h>