Skip to content

Commit

Permalink
Removed usage of MFC "feature pack" classes.
Browse files Browse the repository at this point in the history
The primary goal of this is to remove dependencies on DLLs that are not included in the list of DLLs that are supported on the Windows Server Core configurations. This removes the dependencies on MSIMG32.dll, gdiplus.dll, and WINMM.dll. It also gets rid of a dependency on imm32.dll, but that one is actually supported.

As a side effect, this also reduces the static exe size by about 2 megabytes, but the actual benefit of that ends up being minimal.
  • Loading branch information
mwinterb committed Oct 15, 2015
1 parent 916192f commit 57a5a9a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
11 changes: 5 additions & 6 deletions UIforETW/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.
#include "UIforETW.h"
#include "Settings.h"
#include "Utility.h"
#include "afxdialogex.h"

/*
When doing Chrome profilng it is possible to ask various Chrome tracing
Expand Down Expand Up @@ -64,10 +63,10 @@ uint64_t disabled_other_events_keyword_bit = 1ULL << 62;

// CSettings dialog

IMPLEMENT_DYNAMIC(CSettings, CDialogEx)
IMPLEMENT_DYNAMIC(CSettings, CDialog)

CSettings::CSettings(CWnd* pParent /*=NULL*/, const std::wstring& exeDir, const std::wstring& wptDir, const std::wstring& wpt10Dir)
: CDialogEx(CSettings::IDD, pParent)
: CDialog(CSettings::IDD, pParent)
, exeDir_(exeDir)
, wptDir_(wptDir)
, wpt10Dir_(wpt10Dir)
Expand Down Expand Up @@ -95,11 +94,11 @@ void CSettings::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_VIRTUALALLOCSTACKS, btVirtualAllocStacks_);
DDX_Control(pDX, IDC_CHROME_CATEGORIES, btChromeCategories_);

CDialogEx::DoDataExchange(pDX);
CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSettings, CDialogEx)
BEGIN_MESSAGE_MAP(CSettings, CDialog)
ON_BN_CLICKED(IDC_COPYSTARTUPPROFILE, &CSettings::OnBnClickedCopystartupprofile)
ON_BN_CLICKED(IDC_COPYSYMBOLDLLS, &CSettings::OnBnClickedCopysymboldlls)
ON_BN_CLICKED(IDC_CHROMEDEVELOPER, &CSettings::OnBnClickedChromedeveloper)
Expand All @@ -111,7 +110,7 @@ END_MESSAGE_MAP()

BOOL CSettings::OnInitDialog()
{
CDialogEx::OnInitDialog();
CDialog::OnInitDialog();

SetDlgItemText(IDC_HEAPEXE, heapTracingExes_.c_str());
CheckDlgButton(IDC_CHROMEDEVELOPER, bChromeDeveloper_);
Expand Down
2 changes: 1 addition & 1 deletion UIforETW/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.

// CSettings dialog

class CSettings : public CDialogEx
class CSettings : public CDialog
{
DECLARE_DYNAMIC(CSettings)

Expand Down
8 changes: 0 additions & 8 deletions UIforETW/UIforETW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,6 @@ BOOL CUIforETWApp::InitInstance()

CWinApp::InitInstance();

// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
// Code mysteriously inserted by MFC.
auto pShellManager = std::make_unique<CShellManager>();

// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

SetRegistryKey(L"RandomASCII");

HWND prevWindow = FindWindow(NULL, L"UI for ETW");
Expand Down
14 changes: 7 additions & 7 deletions UIforETW/UIforETWDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ limitations under the License.
#include "UIforETWDlg.h"

#include "About.h"
#include "afxdialogex.h"
#include "ChildProcess.h"
#include "Settings.h"
#include "Utility.h"
Expand All @@ -30,6 +29,7 @@ limitations under the License.
#include <ETWProviders\etwprof.h>
#include <vector>
#include <map>
#include <ShlObj.h>

#ifdef _DEBUG
#define new DEBUG_NEW
Expand Down Expand Up @@ -82,7 +82,7 @@ void CUIforETWDlg::vprintf(const wchar_t* pFormat, va_list args)


CUIforETWDlg::CUIforETWDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CUIforETWDlg::IDD, pParent)
: CDialog(CUIforETWDlg::IDD, pParent)
, monitorThread_(this)
{
pMainWindow = this;
Expand Down Expand Up @@ -169,11 +169,11 @@ void CUIforETWDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_OUTPUT, btOutput_);
DDX_Control(pDX, IDC_TRACENAMEEDIT, btTraceNameEdit_);

CDialogEx::DoDataExchange(pDX);
CDialog::DoDataExchange(pDX);
}

// Hook up functions to messages from buttons, menus, etc.
BEGIN_MESSAGE_MAP(CUIforETWDlg, CDialogEx)
BEGIN_MESSAGE_MAP(CUIforETWDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
Expand Down Expand Up @@ -240,7 +240,7 @@ void CUIforETWDlg::SetSymbolPath()

BOOL CUIforETWDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
CDialog::OnInitDialog();

// Load the F2 (rename) and ESC (silently swallow ESC) accelerators
hAccelTable_ = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATORS));
Expand Down Expand Up @@ -669,7 +669,7 @@ void CUIforETWDlg::OnSysCommand(UINT nID, LPARAM lParam)
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
CDialog::OnSysCommand(nID, lParam);
}
}

Expand Down Expand Up @@ -698,7 +698,7 @@ void CUIforETWDlg::OnPaint()
}
else
{
CDialogEx::OnPaint();
CDialog::OnPaint();
}
}

Expand Down
2 changes: 1 addition & 1 deletion UIforETW/UIforETWDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum TracingMode
kHeapTracingToFile
};

class CUIforETWDlg : public CDialogEx
class CUIforETWDlg : public CDialog
{
public:
CUIforETWDlg(CWnd* pParent = NULL); // standard constructor
Expand Down
1 change: 1 addition & 0 deletions UIforETW/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
#include "Utility.h"
#include <fstream>
#include <direct.h>
#include <ShlObj.h>

std::vector<std::wstring> split(const std::wstring& s, char c)
{
Expand Down
8 changes: 7 additions & 1 deletion UIforETW/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ limitations under the License.
// Include this first so that the requested version is known.
#include "targetver.h"

// disable the MFC "feature pack" controls
// they end up bringing dependencies on DLLs that are not
// documented as available on the Server Core SKUs.
#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
Expand All @@ -39,7 +44,8 @@ limitations under the License.
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#include <afxmt.h>

#include <atlwin.h>
#include <sal.h>
#include <VersionHelpers.h>
Expand Down

0 comments on commit 57a5a9a

Please sign in to comment.