first commit

This commit is contained in:
2026-02-21 17:11:31 +09:00
commit 18b4338361
4001 changed files with 365464 additions and 0 deletions

136
project/webview2/gmap.html Normal file
View File

@@ -0,0 +1,136 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="height: 100% ;width: 100%; padding : 0;margin: 0;">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<head>
<script type="text/javascript">
function gob(e)
{
if(typeof(e)=='object')
return(e);
if(document.getElementById)
return(document.getElementById(e));
return(eval(e))
}
var polylines = [];
var carMarker;
var lineColor = [];
var color1;
var center_last = null;
function initmap()
{
geocoder = new google.maps.Geocoder();
// LONDON 51.5037856,-0.1169808
// TOKYO 35.681382, 139.766084
// TOKYO TOWER 35.6585848,139.7432389
var myOptions = {
zoom: 16,
center: new google.maps.LatLng(35.6585209,139.7453273),
zoomControl:true,
draggableCursor: 'default',
draggingCursor: 'pointer',
scaleControl: true,
scrollwheel: true,
controlSize: 25,
mapTypeControl: true,
mapTypeControlOptions: {
mapTypeIds: [
"roadmap",
"satellite",
"terrain",
"hybrid"
]
},
rotateControl: false,
streetViewControl: true,
fullscreenControl: false
};
map = new google.maps.Map(gob('map_canvas'),myOptions);
}
function moveToMap(Latitude, Longitude) {
var center = new google.maps.LatLng(Latitude, Longitude);
if(!carMarker)
{
carMarker = new google.maps.Marker({ position: center,
map: map,
zIndex: 999,
icon: 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAFS0lEQVRIiZWWaWxVRRTHf29vS2lL2QzG0rTUihRcalWIiEQDRIJUI2GLISTGiApqIiiIkCgRlA+WCNFGlkQQQmhAPtRgYg0Uy1KLgBawQilLwEKhLKWvb7l3xsy8+/C9ex+0/JOTuTPnzPnfc2bmzLiw4cwo+8htlACvAWVAAZBrKdqB08DvwMbBdbLRMTMBLleM0kHcMtJhOxBYAbwKZDq0ybgFVAEf5e+TlxzauxE3P5XUfRZYCxSpjrtXFr7iUrxDRkAgXYu41ka0+S/MpkNSdt2K+zsJvF5wQNb2mPhk2e3PMcA2oL/L5yfj+SlkTn8fz+ChCCGQUuo2LtGW44SrVhPds0NiRpXfNmDKkHq5p0fETaW6GQrsVJG6s/uSO28l6eOmxUhCQaKt53Srf8AXgH6DkF6/7kd+3UZ07VIhb91wW5FPfrBBnrATe+3EpqmbJYpURZo7N0YaudDC1RVvEz15FHf/+3FnZiMB0XEd0XYBT0EJ/rlf4hpdjssQbmP1AolpFFm+pjtSbh9oHM5zwC4gkDV5Nn0XrtaRXF4wFf+IkfSaMgehCBPSLEyDrqpKjMaD+BdVxlK/ZhGiRq0UYWDCsD/l7sSI3Y6IBeWmICDTMsmc9o52YoaCdNbvJn3SLEwpMU0zWYTEM2EGkSN12laNyYmzMH1pQvlSPu08TmKTMpVu39An8OYVEb1xjRvVW3APKkT405yklghfADkgn3DNDkyV/vsGIwoecStfyqedx7nGBnlakR/bvedmjCZ68azWnR01wG7uQPTkElxbK/GuqcYcVIg8clCZ5PUk4j56g/XK0ZFkv7UU6697LK6Z78WykN47PqdPT4hDytgIhfRkb0ExwuUj9/N1ZEx9847knvLZ+BZWYLp8yAcKdbaMUDiuD3WfapMrQN9w67+xycEgwpuGb3gZRjgSP25OFJXAQ48iPH49RxmKK22ImP2VbokNk+NAccfhBvpZGydys4Mzk55GhsPos5QCHcvm4/IHkKEu3KbQxNG/G5Ex4uM9iVjV15e7mk/RXrWRwIjSWJS3gmSMHU/WnPlIfX6tkimF7nd+V0H0txrtQ7g9mD/vxDgX25QXTRrj5zcOj514ZhpNUlIuJf2il1rp/dIUhGHizSsk/cVX8BYWIzN6/S/plvTORuDGNewxXMMfJ7Lua0T7VYKCCx/fZPM1ScBKuc6Zo3JVZ+tmMfCp0meOHcfA5asQ1qWgd2ti1bKJir5r+ScY+/XFJBsNNn/YyVbLfXM87Y6Ip/tASmqlpERKHg6fbqbr6GF8RcWQnZNEpCtUwi1ltDQTXLkMo36/8kGryb55QSoT3KuoW1JG/GP67U/1ADgA5KuOOyubjBfGk/bMGPylZUk/EG6oJ1JXS2RPDbKjQ08OweXPwnxwTHA9cQsBP6Uk3h5I6s4AvrdnxtN/AK6cHJ0a0d6u1zIREsRewVcVUZLuYiAI6B3o2NUi+bhsBsYBs5JsLl0GJXfARcnuCsNBSuJ57o5YYT7wpPU46BZdcH6NYEMKOxVtU7zjKJmK2CZtQrBYLWUKXZKYgug+waYmyQ2bW1UyG6w2NbHajSlku5SsTzGeJOclv1RK9ttcqjX5A5J/xkF8Fyy2HKREJzR/A5sSdF3AMUDdi1ftc+6FuN16P3XaFQJCdfBDC3RYlek8sNd66KfEvRArVAPf2gfPwq4NsTVUZ/YQcMR6a90RjnO85U6WyVCFRT/9O+CfN+DdGD+n1CPEYZ0C9xpxHPNUdBJu1sIXwP4tcGJLD0kVHOe4h6gHVql0TYT1ExMmqdp9N+jrEfgP4vQlN0VUoHYAAAAASUVORK5CYII='
});
}
else
{
carMarker.setPosition(center);
}
map.panTo(center);
}
function clearPath()
{
if(polylines.length > 0)
{
for(var idx in polylines) {
var polyline = polylines[idx]
polyline.setMap(null);
}
polylines = []
}
if(carMarker)
{
carMarker.setMap(null);
carMarker = null;
}
}
function clearCarMarker()
{
if(carMarker)
{
carMarker.setMap(null);
carMarker = null;
}
}
function drawPaths(pathArray)
{
var first = null;
clearPath();
for(var idx in pathArray) {
var path = pathArray[idx];
if(first == null) {
first = path[0];
}
if(path.length > 1) {
polyline = new google.maps.Polyline({map: map,
path: path,
strokeColor: "#FF0000",
strokeOpacity: 0.7,
strokeWeight: 4
});
polylines.push(polyline);
}
}
if(first != null)
{
//alert(first["lat"]);
var center = new google.maps.LatLng(first["lat"], first["lng"]);
map.panTo(center);
}
}
</script>
<!-- 20220520 제거 v=3.45& v=3.47 하면 동작하나 user-agent 처리방법 -->
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCPUaVeDlLr6nsEaKJIODW9nS5iWaVNLTM&sensor=false&region=JP&language=ja&callback=initmap"async defer></script>
</head>
<!-- -->
<body oncontextmenu="return false;" style="width: 100%; height: 100%; padding : 0;margin: 0;">
<div id="map_canvas" style="overflow-x:hidden; overflow-y:hidden; width: 100%; height: 100%; padding : 0;margin: 0;"></div>
</div>
</body>
</html>

View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

334
project/webview2/project/.gitignore vendored Normal file
View File

@@ -0,0 +1,334 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Kunihiro Ando
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,90 @@
# WebView2dll for VC++ App
<br><br>
Windows10
Webview2 Runtime (required)
https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section
<br>
Windows 11
Webview2 Runtime installed by default
<br><br><br>
Webview2
https://docs.microsoft.com/en-us/microsoft-edge/webview2/
<br><br><br>
WebV2dll.h
WebV2dll.lib
WebV2dll.dll
WebView2Loader.dll
<br><br><br>
<pre>
#include "WebV2dll.h"
#pragma comment(lib, "WebV2dll.lib")
#define WM_JSMSG (WM_APP + 1)
</pre>
<br>
<pre>
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
create_webview2(hWnd, 0, L"https://www.google.com/");
//create_webview2(hWnd, 0, L"C:\\html\\index.html");
</pre>
<br>
<pre>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
...
// add
case WM_JSMSG: {
COPYDATASTRUCT* copy_data_structure = { 0 };
copy_data_structure = (COPYDATASTRUCT*)lParam;
LPCWSTR arguments = (LPCWSTR)copy_data_structure->lpData;
OutputDebugString(arguments);
} break;
case WM_SIZE: {
resize_webview(hWnd);
} break;
}
</pre>

View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebV2dll", "WebV2dll\WebV2dll.vcxproj", "{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Debug|x64.ActiveCfg = Debug|x64
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Debug|x64.Build.0 = Debug|x64
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Debug|x86.ActiveCfg = Debug|Win32
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Debug|x86.Build.0 = Debug|Win32
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Release|x64.ActiveCfg = Release|x64
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Release|x64.Build.0 = Release|x64
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Release|x86.ActiveCfg = Release|Win32
{134A3922-05E2-41A4-B7DD-1F51DC5EBE4E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA041136-857D-47D2-87AE-7FD7E586EE79}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{134a3922-05e2-41a4-b7dd-1f51dc5ebe4e}</ProjectGuid>
<RootNamespace>WebV2dll</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>libwebview2</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;WEBV2DLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;WEBV2DLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<Optimization>MinSpace</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;WEBV2DLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;WEBV2DLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="libwebview2.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.211019.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.211019.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1185.39\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1185.39\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.211019.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.211019.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1185.39\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1185.39\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
<PropertyGroup>
<WebView2LoaderPreference>Static</WebView2LoaderPreference>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="libwebview2.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,317 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <combaseapi.h>
#include <commctrl.h>
#include <stdlib.h>
#include <string>
#include <tchar.h>
#include <vector>
#include <wil/com.h>
#include <wrl.h>
#include "libwebview2.h"
#include "WebView2.h"
#pragma comment(lib, "comctl32.lib")
#define WM_WEBV_USER (WM_APP + 0)
#define WM_JSMSG (WM_APP + 1)
#define G_BUFFER_SIZE (1024 * 100)
static TCHAR g_buffer[G_BUFFER_SIZE] = { 0, };
static webview2_callback_t g_call_back = NULL;
void set_g_callback(webview2_callback_t f)
{
g_call_back = f;
}
const TCHAR* strClassName = TEXT("CREATE_WEBVIEW2");
using namespace Microsoft::WRL;
struct windowobj {
HWND hwnd = nullptr;
wil::com_ptr<ICoreWebView2> webviewWindow = nullptr;
wil::com_ptr<ICoreWebView2Controller> webviewController = nullptr;
wil::com_ptr<ICoreWebView2_2> webView2 = nullptr;
std::wstring startup_script = L"";
int createid = -1;
};
HINSTANCE hInst;
int g_randomid = 0;
std::wstring g_startup_script = L"";
std::vector<windowobj> m_windowobjs;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void create_randomid()
{
g_randomid = 0;
}
int get_current_windowobj_idx(HWND hwnd)
{
for (int i = 0; i < m_windowobjs.size(); i++) {
if (m_windowobjs[i].hwnd == hwnd) {
return i;
}
}
return -1;
}
void load_url(HWND hWnd, const TCHAR* url)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].webviewWindow->Navigate(url);
}
void resize_webview(HWND hWnd)
{
int idx = get_current_windowobj_idx(hWnd);
if (idx == -1)
return;
if (m_windowobjs[idx].webviewController != nullptr) {
RECT bounds;
GetClientRect(m_windowobjs[idx].hwnd, &bounds);
m_windowobjs[idx].webviewController->put_Bounds(bounds);
};
}
void set_copydata(HWND hWnd, std::wstring s, int wmmsg)
{
DWORD bytes = (s.size()+10) * sizeof(wchar_t);
TCHAR* buffer = new TCHAR[s.length() + 1];
wcscpy_s(buffer, s.length() + 1, s.c_str());
if (g_call_back != NULL) {
g_call_back(buffer);
}
COPYDATASTRUCT data_to_send = { 0 };
data_to_send.dwData = g_randomid;
data_to_send.cbData = bytes;
data_to_send.lpData = buffer;
SendMessage(hWnd, wmmsg, 0, (LPARAM)&data_to_send);
delete[] buffer;
}
LPTSTR get_webview2_version()
{
memset(g_buffer, 0, sizeof(TCHAR) * G_BUFFER_SIZE);
LPWSTR version = NULL;
GetAvailableCoreWebView2BrowserVersionString(nullptr, &version);
if (version != NULL) {
wcscpy_s(g_buffer, version);
CoTaskMemFree(version);
}
return g_buffer;
}
LPTSTR get_udf_path()
{
memset(g_buffer, 0, sizeof(TCHAR) * G_BUFFER_SIZE);
DWORD path_len = ::GetTempPathW(G_BUFFER_SIZE, g_buffer);
size_t remaining_size = G_BUFFER_SIZE - path_len;
// wcscpy_s는 안전한 문자열 복사 함수입니다.
wcscpy_s(&g_buffer[path_len], remaining_size, L"mapview\\");
// 4. 'mapview' 폴더가 있는지 확인하고 없으면 생성합니다.
DWORD attributes = ::GetFileAttributesW(g_buffer);
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
// 폴더가 존재하지 않으면 생성
if (!::CreateDirectoryW(g_buffer, nullptr)) {
// 폴더 생성 실패 시 nullptr 반환
return nullptr;
}
}
return g_buffer;
}
LPTSTR get_msg_string(LPARAM lp)
{
COPYDATASTRUCT* copy_data_structure = { 0 };
copy_data_structure = (COPYDATASTRUCT*)lp;
LPCWSTR arguments = (LPCWSTR)copy_data_structure->lpData;
return (LPTSTR)arguments;
}
void set_jsmsg_to_copydata(HWND hWnd, std::wstring s)
{
set_copydata(hWnd, s, WM_JSMSG);
}
HWND get_main_hwnd(int createid)
{
for (int i = 0; i < m_windowobjs.size(); i++) {
if (m_windowobjs[i].createid == createid) {
return m_windowobjs[i].hwnd;
}
}
return nullptr;
}
void close_window(HWND hWnd)
{
PostMessage(hWnd, WM_CLOSE, 0, 0);
}
void reload_page(HWND hWnd)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].webviewWindow->Reload();
}
void set_startup_script(HWND hWnd, const TCHAR* script)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].startup_script = script;
}
void set_global_startup_script(const TCHAR* script)
{
g_startup_script = script;
}
void exec_js(HWND hWnd, const TCHAR* script)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].webviewWindow->ExecuteScript(script,
Callback<ICoreWebView2ExecuteScriptCompletedHandler>([hWnd](HRESULT error, PCWSTR result) -> HRESULT {
std::wstring msgstr = L"{\"msg\"\:\"exec_js_done\"}";
set_jsmsg_to_copydata(hWnd, msgstr);
return S_OK;
}).Get());
}
void send_json(HWND hWnd, const TCHAR* jsonstr)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].webviewWindow->PostWebMessageAsJson(jsonstr);
}
void close_window_event(HWND hWnd)
{
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs.erase(m_windowobjs.begin() + idx);
if (m_windowobjs.size() < 1) {
PostQuitMessage(0);
}
}
void CHECK_FAILURE(HRESULT hr)
{
if (FAILED(hr)) {
std::wstring message;
message = std::wstring(L"Something went wrong.");
MessageBoxW(nullptr, message.c_str(), nullptr, MB_OK);
}
}
void webview_events(HWND hWnd)
{
int idx = get_current_windowobj_idx(hWnd);
EventRegistrationToken token;
m_windowobjs[idx].webviewWindow->add_WebMessageReceived(
Callback<ICoreWebView2WebMessageReceivedEventHandler>(
[hWnd](ICoreWebView2* webview, ICoreWebView2WebMessageReceivedEventArgs* args) -> HRESULT {
wil::unique_cotaskmem_string source;
CHECK_FAILURE(args->get_Source(&source));
wil::unique_cotaskmem_string webMessageAsJson;
CHECK_FAILURE(args->get_WebMessageAsJson(&webMessageAsJson));
Sleep(200);
set_jsmsg_to_copydata(hWnd, webMessageAsJson.get());
return S_OK;
})
.Get(),
&token);
std::wstring script = g_startup_script;
if (4 < m_windowobjs[idx].startup_script.length())
script = m_windowobjs[idx].startup_script;
m_windowobjs[idx].webviewWindow->AddScriptToExecuteOnDocumentCreated(script.c_str(),
Callback<ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler>(
[](HRESULT error, PCWSTR id) -> HRESULT {
return S_OK;
})
.Get());
EventRegistrationToken m_DOMContentLoadedToken;
wil::com_ptr<ICoreWebView2_2> webView2;
m_windowobjs[idx].webviewWindow->QueryInterface(IID_PPV_ARGS(&webView2));
m_windowobjs[idx].webView2 = webView2;
webView2->add_DOMContentLoaded(
Callback<ICoreWebView2DOMContentLoadedEventHandler>(
[hWnd](ICoreWebView2* sender, ICoreWebView2DOMContentLoadedEventArgs* args) -> HRESULT {
std::wstring msgstr = L"{\"msg\"\:\"DOMContentLoaded\"}";
set_jsmsg_to_copydata(hWnd, msgstr);
return S_OK;
})
.Get(),
&m_DOMContentLoadedToken);
}
void init_webview2(HWND hWnd, std::wstring url2str)
{
//WCHAR path[MAX_PATH] = { 0, };
//::GetTempPathW(MAX_PATH, path);
CreateCoreWebView2EnvironmentWithOptions(nullptr, get_udf_path(), nullptr,
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
[hWnd, url2str](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {
env->CreateCoreWebView2Controller(hWnd,
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
[hWnd, url2str](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT {
wil::com_ptr<ICoreWebView2> webviewWindow;
if (controller != nullptr) {
auto webviewController = controller;
webviewController->get_CoreWebView2(&webviewWindow);
int idx = get_current_windowobj_idx(hWnd);
m_windowobjs[idx].webviewController = controller;
m_windowobjs[idx].webviewWindow = webviewWindow;
wil::com_ptr<ICoreWebView2Controller4> controller4 =
m_windowobjs[idx].webviewController.try_query<ICoreWebView2Controller4>();
if (controller4 != nullptr) {
controller4->put_AllowExternalDrop(FALSE);
}
}
ICoreWebView2Settings* Settings;
webviewWindow->get_Settings(&Settings);
Settings->put_IsScriptEnabled(TRUE);
Settings->put_AreDefaultScriptDialogsEnabled(TRUE);
Settings->put_IsWebMessageEnabled(TRUE);
Settings->put_AreDefaultContextMenusEnabled(FALSE);
Settings->put_IsZoomControlEnabled(FALSE);
Settings->put_IsStatusBarEnabled(FALSE);
resize_webview(hWnd);
webview_events(hWnd);
load_url(hWnd, url2str.c_str());
return S_OK;
})
.Get());
return S_OK;
})
.Get());
}
bool create_webview2(HWND hWnd, int createid, const TCHAR* url)
{
if (hWnd == NULL)
return false;
windowobj wobj;
wobj.hwnd = hWnd;
wobj.webviewWindow = nullptr;
wobj.webviewController = nullptr;
wobj.webView2 = nullptr;
wobj.startup_script = L"";
wobj.createid = createid;
m_windowobjs.push_back(wobj);
std::wstring url2str = url;
init_webview2(hWnd, url2str);
return true;
}

View File

@@ -0,0 +1,5 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>

View File

@@ -0,0 +1,31 @@
#pragma once
#include <Windows.h>
#ifdef WEBV2DLL_EXPORTS
#define __DLL_PORT extern "C" __declspec(dllexport)
#else
#define __DLL_PORT extern "C" __declspec(dllimport)
#endif
typedef void(__stdcall* webview2_callback_t)(TCHAR*);
__DLL_PORT bool create_webview2(HWND hWnd, int createid, const TCHAR* url);
__DLL_PORT HWND get_main_hwnd(int createid);
__DLL_PORT void close_window(HWND hWnd);
__DLL_PORT void resize_webview(HWND hWnd);
__DLL_PORT void load_url(HWND hWnd, const TCHAR* url);
__DLL_PORT void reload_page(HWND hWnd);
__DLL_PORT void set_startup_script(HWND hWnd, const TCHAR* script);
__DLL_PORT void set_global_startup_script(const TCHAR* script);
__DLL_PORT void exec_js(HWND hWnd, const TCHAR* script);
__DLL_PORT void send_json(HWND hWnd, const TCHAR* jsonstr);
__DLL_PORT LPTSTR get_msg_string(LPARAM lp);
__DLL_PORT LPTSTR get_udf_path();
__DLL_PORT LPTSTR get_webview2_version();
__DLL_PORT void set_g_callback(webview2_callback_t f);

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.1185.39" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.211019.2" targetFramework="native" />
</packages>

View File

@@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@@ -0,0 +1,13 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#endif //PCH_H

View File

@@ -0,0 +1,6 @@
rd /s /q Release
rd /s /q packages
rd /s /q x64
rd /s /q WebV2dll\Release
rd /s /q WebV2dll\x64
rd /s /q .vs

View File

@@ -0,0 +1,5 @@
copy /Y WebV2dll\libwebview2.h C:\home\roadmovie\project\webview2\webview2
copy /Y Release\libwebview2.dll C:\home\roadmovie\project\webview2\webview2
copy /Y Release\libwebview2.lib C:\home\roadmovie\project\webview2\webview2
copy /Y Release\libwebview2.dll C:\tools\dlls

Binary file not shown.

View File

@@ -0,0 +1,33 @@
#pragma once
#ifdef Q_OS_WIN
#include <Windows.h>
#ifdef WEBV2DLL_EXPORTS
#define __DLL_PORT extern "C" __declspec(dllexport)
#else
#define __DLL_PORT extern "C" __declspec(dllimport)
#endif
typedef void(__stdcall* webview2_callback_t)(TCHAR*);
__DLL_PORT bool create_webview2(HWND hWnd, int createid, const TCHAR* url);
__DLL_PORT HWND get_main_hwnd(int createid);
__DLL_PORT void close_window(HWND hWnd);
__DLL_PORT void resize_webview(HWND hWnd);
__DLL_PORT void load_url(HWND hWnd, const TCHAR* url);
__DLL_PORT void reload_page(HWND hWnd);
__DLL_PORT void set_startup_script(HWND hWnd, const TCHAR* script);
__DLL_PORT void set_global_startup_script(const TCHAR* script);
__DLL_PORT void exec_js(HWND hWnd, const TCHAR* script);
__DLL_PORT void send_json(HWND hWnd, const TCHAR* jsonstr);
__DLL_PORT LPTSTR get_msg_string(LPARAM lp);
__DLL_PORT LPTSTR get_udf_path();
__DLL_PORT LPTSTR get_webview2_version();
__DLL_PORT void set_g_callback(webview2_callback_t f);
#endif // #ifdef Q_OS_WIN

Binary file not shown.

View File

@@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@@ -0,0 +1,52 @@
#include "mainwindow.h"
#include "libwebview2.h"
#include <Windows.h>
//#pragma comment(lib, "./webview2/WebV2dll.lib")
#define WM_JSMSG (WM_APP + 1)
#include <QDebug>
// https://github.com/kxkx5150/WebV2dll
//LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//{
// switch (message)
// {
// // add
// case WM_JSMSG: {
// COPYDATASTRUCT* copy_data_structure = { 0 };
// copy_data_structure = (COPYDATASTRUCT*)lParam;
// LPCWSTR arguments = (LPCWSTR)copy_data_structure->lpData;
// OutputDebugString(arguments);
// } break;
// case WM_SIZE: {
// resize_webview(hWnd);
// } break;
//}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
resize(640,480);
HWND hWnd = (HWND)winId();
QString s = QString::fromWCharArray(get_udf_path());
QString v = QString::fromWCharArray(get_webview2_version());
qInfo() << s << v << __FUNCTION__;
//
create_webview2(hWnd, 0, L"C:\\home\\roadmovie\\project\\webview2\\gmap.html");
//create_webview2(hWnd, 0, L"edge://gpu");
//qInfo() << "INFO:" << get_msg_string(0);
//qInfo() << "CREATE:" << create_webview2(hWnd, 0, L"https://maps.google.com");
//qInfo() << "CREATE:" << create_webview2(hWnd, 0, L"https://www.whatismybrowser.com/detect/what-is-my-user-agent/");
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
resize_webview((HWND)winId());
}
MainWindow::~MainWindow()
{
}

View File

@@ -0,0 +1,15 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void resizeEvent(QResizeEvent* event);
};
#endif // MAINWINDOW_H

View File

@@ -0,0 +1,24 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
LIBS += -LC:\home\roadmovie\project\webview2\webview2 -llibwebview2
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
WebV2dll.h \
mainwindow.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

Binary file not shown.

View File

@@ -0,0 +1,31 @@
#pragma once
#include <Windows.h>
#ifdef WEBV2DLL_EXPORTS
#define __DLL_PORT extern "C" __declspec(dllexport)
#else
#define __DLL_PORT extern "C" __declspec(dllimport)
#endif
typedef void(__stdcall* webview2_callback_t)(TCHAR*);
__DLL_PORT bool create_webview2(HWND hWnd, int createid, const TCHAR* url);
__DLL_PORT HWND get_main_hwnd(int createid);
__DLL_PORT void close_window(HWND hWnd);
__DLL_PORT void resize_webview(HWND hWnd);
__DLL_PORT void load_url(HWND hWnd, const TCHAR* url);
__DLL_PORT void reload_page(HWND hWnd);
__DLL_PORT void set_startup_script(HWND hWnd, const TCHAR* script);
__DLL_PORT void set_global_startup_script(const TCHAR* script);
__DLL_PORT void exec_js(HWND hWnd, const TCHAR* script);
__DLL_PORT void send_json(HWND hWnd, const TCHAR* jsonstr);
__DLL_PORT LPTSTR get_msg_string(LPARAM lp);
__DLL_PORT LPTSTR get_udf_path();
__DLL_PORT LPTSTR get_webview2_version();
__DLL_PORT void set_g_callback(webview2_callback_t f);

Binary file not shown.