Skip to content

Commit def7237

Browse files
authored
Merge pull request #70 from MicrosoftEdge/smoketesting
Update projects to use latest WebView2 SDK 1.0.721-prerelease
2 parents eecf384 + 7a60335 commit def7237

File tree

11 files changed

+1453
-1447
lines changed

11 files changed

+1453
-1447
lines changed

SampleApps/WebView2APISample/AppStartPage.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
#include "stdafx.h"
66

7-
#include <algorithm>
7+
#ifdef USE_WEBVIEW2_WIN10
88
#include <pathcch.h>
9+
#else
10+
#include <Shlwapi.h>
11+
#endif
912
#include <Psapi.h>
1013

1114
#include "AppStartPage.h"
@@ -31,8 +34,16 @@ bool AreFileUrisEqual(std::wstring leftUri, std::wstring rightUri)
3134
std::wstring ResolvePathAndTrimFile(std::wstring path)
3235
{
3336
wchar_t resultPath[MAX_PATH];
37+
#ifdef USE_WEBVIEW2_WIN10
3438
PathCchCanonicalize(resultPath, ARRAYSIZE(resultPath), path.c_str());
3539
PathCchRemoveFileSpec(resultPath, ARRAYSIZE(resultPath));
40+
#else
41+
// Surpress compiler warning for PathCanonicalize. It is only used on Win7
42+
// where PathCchCanonicalize doesn't exist.
43+
#pragma warning(suppress : 4995)
44+
PathCanonicalize(resultPath, path.c_str());
45+
PathRemoveFileSpec(resultPath);
46+
#endif
3647
return resultPath;
3748
}
3849

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,12 +1245,14 @@ double AppWindow::GetDpiScale()
12451245
return DpiUtil::GetDpiForWindow(m_mainWindow) * 1.0f / USER_DEFAULT_SCREEN_DPI;
12461246
}
12471247

1248-
#ifdef USE_WEBVIEW2_WIN10
12491248
double AppWindow::GetTextScale()
12501249
{
1250+
#ifdef USE_WEBVIEW2_WIN10
12511251
return m_uiSettings ? m_uiSettings.TextScaleFactor() : 1.0f;
1252-
}
1252+
#else
1253+
return 1.0f;
12531254
#endif
1255+
}
12541256

12551257
void AppWindow::AddRef()
12561258
{

SampleApps/WebView2APISample/AppWindow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ class AppWindow
5858
std::wstring GetLocalUri(std::wstring path);
5959
std::function<void()> GetAcceleratorKeyFunction(UINT key);
6060
double GetDpiScale();
61-
#ifdef USE_WEBVIEW2_WIN10
6261
double GetTextScale();
63-
#endif
6462

6563
void ReinitializeWebView();
6664

SampleApps/WebView2APISample/Toolbar.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,9 @@ void Toolbar::UpdateFont()
137137
LOGFONT logFont;
138138
GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &logFont);
139139
double dpiScale = m_appWindow->GetDpiScale();
140-
#ifdef USE_WEBVIEW2_WIN10
141140
double textScale = m_appWindow->GetTextScale();
142141
logFont.lfHeight *= dpiScale * textScale;
143142
logFont.lfWidth *= dpiScale * textScale;
144-
#else
145-
logFont.lfHeight *= dpiScale;
146-
logFont.lfWidth *= dpiScale;
147-
#endif
148143
StringCchCopy(logFont.lfFaceName, ARRAYSIZE(logFont.lfFaceName), s_fontName);
149144
m_font = CreateFontIndirect(&logFont);
150145
}

0 commit comments

Comments
 (0)