Skip to content

Commit fbbe67c

Browse files
committed
Initial commit
0 parents  commit fbbe67c

File tree

6 files changed

+346
-0
lines changed

6 files changed

+346
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# VS Code
2+
.vscode/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# HelloWebView - start
2+
3+
Starting point for [Microsoft Edge WebView2 getting-started guide](https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2/gettingstarted).

WebView2Sample.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.539
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebView2Sample", "WebView2Sample\WebView2Sample.vcxproj", "{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Debug|x64.ActiveCfg = Debug|x64
17+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Debug|x64.Build.0 = Debug|x64
18+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Debug|x86.ActiveCfg = Debug|Win32
19+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Debug|x86.Build.0 = Debug|Win32
20+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Release|x64.ActiveCfg = Release|x64
21+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Release|x64.Build.0 = Release|x64
22+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Release|x86.ActiveCfg = Release|Win32
23+
{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {208302FF-DCD8-4EA4-8480-00B3FEFADB00}
30+
EndGlobalSection
31+
EndGlobal

WebView2Sample/HelloWebView.cpp

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c
2+
3+
#include <windows.h>
4+
#include <stdlib.h>
5+
#include <string>
6+
#include <tchar.h>
7+
#include <wrl.h>
8+
9+
using namespace Microsoft::WRL;
10+
11+
// Global variables
12+
13+
// The main window class name.
14+
static TCHAR szWindowClass[] = _T("DesktopApp");
15+
16+
// The string that appears in the application's title bar.
17+
static TCHAR szTitle[] = _T("WebView sample");
18+
19+
HINSTANCE hInst;
20+
21+
// Forward declarations of functions included in this code module:
22+
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
23+
24+
int CALLBACK WinMain(
25+
_In_ HINSTANCE hInstance,
26+
_In_ HINSTANCE hPrevInstance,
27+
_In_ LPSTR lpCmdLine,
28+
_In_ int nCmdShow
29+
)
30+
{
31+
WNDCLASSEX wcex;
32+
33+
wcex.cbSize = sizeof(WNDCLASSEX);
34+
wcex.style = CS_HREDRAW | CS_VREDRAW;
35+
wcex.lpfnWndProc = WndProc;
36+
wcex.cbClsExtra = 0;
37+
wcex.cbWndExtra = 0;
38+
wcex.hInstance = hInstance;
39+
wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
40+
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
41+
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
42+
wcex.lpszMenuName = NULL;
43+
wcex.lpszClassName = szWindowClass;
44+
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION);
45+
46+
if (!RegisterClassEx(&wcex))
47+
{
48+
MessageBox(NULL,
49+
_T("Call to RegisterClassEx failed!"),
50+
_T("Windows Desktop Guided Tour"),
51+
NULL);
52+
53+
return 1;
54+
}
55+
56+
// Store instance handle in our global variable
57+
hInst = hInstance;
58+
59+
// The parameters to CreateWindow explained:
60+
// szWindowClass: the name of the application
61+
// szTitle: the text that appears in the title bar
62+
// WS_OVERLAPPEDWINDOW: the type of window to create
63+
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
64+
// 500, 100: initial size (width, length)
65+
// NULL: the parent of this window
66+
// NULL: this application does not have a menu bar
67+
// hInstance: the first parameter from WinMain
68+
// NULL: not used in this application
69+
HWND hWnd = CreateWindow(
70+
szWindowClass,
71+
szTitle,
72+
WS_OVERLAPPEDWINDOW,
73+
CW_USEDEFAULT, CW_USEDEFAULT,
74+
1200, 900,
75+
NULL,
76+
NULL,
77+
hInstance,
78+
NULL
79+
);
80+
81+
if (!hWnd)
82+
{
83+
MessageBox(NULL,
84+
_T("Call to CreateWindow failed!"),
85+
_T("Windows Desktop Guided Tour"),
86+
NULL);
87+
88+
return 1;
89+
}
90+
91+
// The parameters to ShowWindow explained:
92+
// hWnd: the value returned from CreateWindow
93+
// nCmdShow: the fourth parameter from WinMain
94+
ShowWindow(hWnd,
95+
nCmdShow);
96+
UpdateWindow(hWnd);
97+
98+
// <-- WebView2 sample code starts here -->
99+
100+
101+
102+
// <-- WebView2 sample code ends here -->
103+
104+
// Main message loop:
105+
MSG msg;
106+
while (GetMessage(&msg, NULL, 0, 0))
107+
{
108+
TranslateMessage(&msg);
109+
DispatchMessage(&msg);
110+
}
111+
112+
return (int)msg.wParam;
113+
}
114+
115+
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
116+
//
117+
// PURPOSE: Processes messages for the main window.
118+
//
119+
// WM_DESTROY - post a quit message and return
120+
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
121+
{
122+
TCHAR greeting[] = _T("Hello, Windows desktop!");
123+
124+
switch (message)
125+
{
126+
case WM_DESTROY:
127+
PostQuitMessage(0);
128+
break;
129+
default:
130+
return DefWindowProc(hWnd, message, wParam, lParam);
131+
break;
132+
}
133+
134+
return 0;
135+
}

WebView2Sample/WebView2Sample.vcxproj

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{A1238CE8-5AF4-4BBB-9821-E6BBB0D44F75}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>WebViewSample</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
<ProjectName>WebView2Sample</ProjectName>
28+
</PropertyGroup>
29+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
30+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
31+
<ConfigurationType>Application</ConfigurationType>
32+
<UseDebugLibraries>true</UseDebugLibraries>
33+
<PlatformToolset>v142</PlatformToolset>
34+
<CharacterSet>Unicode</CharacterSet>
35+
</PropertyGroup>
36+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
37+
<ConfigurationType>Application</ConfigurationType>
38+
<UseDebugLibraries>false</UseDebugLibraries>
39+
<PlatformToolset>v142</PlatformToolset>
40+
<WholeProgramOptimization>true</WholeProgramOptimization>
41+
<CharacterSet>Unicode</CharacterSet>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
44+
<ConfigurationType>Application</ConfigurationType>
45+
<UseDebugLibraries>true</UseDebugLibraries>
46+
<PlatformToolset>v142</PlatformToolset>
47+
<CharacterSet>Unicode</CharacterSet>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
50+
<ConfigurationType>Application</ConfigurationType>
51+
<UseDebugLibraries>false</UseDebugLibraries>
52+
<PlatformToolset>v142</PlatformToolset>
53+
<WholeProgramOptimization>true</WholeProgramOptimization>
54+
<CharacterSet>Unicode</CharacterSet>
55+
</PropertyGroup>
56+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
57+
<ImportGroup Label="ExtensionSettings">
58+
</ImportGroup>
59+
<ImportGroup Label="Shared">
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
</ImportGroup>
67+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
68+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69+
</ImportGroup>
70+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
71+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
72+
</ImportGroup>
73+
<PropertyGroup Label="UserMacros" />
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
75+
<LinkIncremental>true</LinkIncremental>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
78+
<LinkIncremental>true</LinkIncremental>
79+
</PropertyGroup>
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
81+
<LinkIncremental>false</LinkIncremental>
82+
</PropertyGroup>
83+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
84+
<LinkIncremental>false</LinkIncremental>
85+
</PropertyGroup>
86+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
87+
<ClCompile>
88+
<WarningLevel>Level3</WarningLevel>
89+
<Optimization>Disabled</Optimization>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
</ClCompile>
94+
<Link>
95+
<GenerateDebugInformation>true</GenerateDebugInformation>
96+
<SubSystem>Windows</SubSystem>
97+
</Link>
98+
</ItemDefinitionGroup>
99+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
100+
<ClCompile>
101+
<WarningLevel>Level3</WarningLevel>
102+
<Optimization>Disabled</Optimization>
103+
<SDLCheck>true</SDLCheck>
104+
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105+
<ConformanceMode>true</ConformanceMode>
106+
</ClCompile>
107+
<Link>
108+
<GenerateDebugInformation>true</GenerateDebugInformation>
109+
<SubSystem>Windows</SubSystem>
110+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<Optimization>MaxSpeed</Optimization>
117+
<FunctionLevelLinking>true</FunctionLevelLinking>
118+
<IntrinsicFunctions>true</IntrinsicFunctions>
119+
<SDLCheck>true</SDLCheck>
120+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121+
<ConformanceMode>true</ConformanceMode>
122+
</ClCompile>
123+
<Link>
124+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
125+
<OptimizeReferences>true</OptimizeReferences>
126+
<GenerateDebugInformation>true</GenerateDebugInformation>
127+
<SubSystem>Windows</SubSystem>
128+
</Link>
129+
</ItemDefinitionGroup>
130+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
131+
<ClCompile>
132+
<WarningLevel>Level3</WarningLevel>
133+
<Optimization>MaxSpeed</Optimization>
134+
<FunctionLevelLinking>true</FunctionLevelLinking>
135+
<IntrinsicFunctions>true</IntrinsicFunctions>
136+
<SDLCheck>true</SDLCheck>
137+
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
138+
<ConformanceMode>true</ConformanceMode>
139+
</ClCompile>
140+
<Link>
141+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
142+
<OptimizeReferences>true</OptimizeReferences>
143+
<GenerateDebugInformation>true</GenerateDebugInformation>
144+
<SubSystem>Windows</SubSystem>
145+
</Link>
146+
</ItemDefinitionGroup>
147+
<ItemGroup>
148+
<ClCompile Include="HelloWebView.cpp" />
149+
</ItemGroup>
150+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
151+
<ImportGroup Label="ExtensionTargets">
152+
</ImportGroup>
153+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="HelloWebView.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>

0 commit comments

Comments
 (0)