Skip to content

Commit

Permalink
Readme improvements (webview#782)
Browse files Browse the repository at this point in the history
* Add -mwindows flag in C/C++ examples in readme

This gets rid of the console for GUI applications.

* Add more helpful info about icons on Windows

The important detail to document here is the window icon because the library loads the icon that has an ID of IDI_APPLICATION which will either be the default application icon or a user-defined icon with that ID.

* Remind to bundle shared libraries from MinGW-w64.
  • Loading branch information
SteffenL authored Jun 23, 2022
1 parent 714cde9 commit c48a9a8
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ g++ basic.cc -std=c++11 -Ilibs/webview $(pkg-config --cflags --libs gtk+-3.0 web
# macOS
g++ basic.cc -std=c++11 -Ilibs/webview -framework WebKit -o build/basic && ./build/basic
# Windows/MinGW
g++ basic.cc -std=c++17 -Ilibs/webview -Ilibs/webview2/build/native/include -Llibs/webview2/build/native/x64 -lWebView2Loader.dll -lole32 -lshell32 -lshlwapi -luser32 -o build/basic.exe && "build/basic.exe"
g++ basic.cc -std=c++17 -mwindows -Ilibs/webview -Ilibs/webview2/build/native/include -Llibs/webview2/build/native/x64 -lWebView2Loader.dll -lole32 -lshell32 -lshlwapi -luser32 -o build/basic.exe && "build/basic.exe"
```

#### Bonus for Visual C++
Expand Down Expand Up @@ -152,7 +152,7 @@ g++ build/basic.o build/webview.o -framework WebKit -o build/basic && build/basi
# Windows/MinGW
g++ -c libs/webview/webview.cc -std=c++17 -Ilibs/webview2/build/native/include -o build/webview.o
gcc -c basic.c -std=c99 -Ilibs/webview -o build/basic.o
g++ build/basic.o build/webview.o -Llibs/webview2/build/native/x64 -lWebView2Loader.dll -lole32 -lshell32 -lshlwapi -luser32 -o build/basic.exe && "build/basic.exe"
g++ build/basic.o build/webview.o -mwindows -Llibs/webview2/build/native/x64 -lWebView2Loader.dll -lole32 -lshell32 -lshlwapi -luser32 -o build/basic.exe && "build/basic.exe"
```

### Getting Started with Go
Expand Down Expand Up @@ -236,7 +236,32 @@ Read more about the [structure of bundles][macos-app-bundle] at the Apple Develo

You would typically create a resource script file (`*.rc`) with information about the app as well as an icon. Since you should have MinGW-w64 readily available then you can compile the file using `windres` and link it into your program. If you instead use Visual C++ then look into the [Windows Resource Compiler][win32-rc].

Remember to bundle `WebView2Loader.dll` unless you linked it statically.
The directory structure could look like this:

```
my-project/
├── icons/
| ├── application.ico
| └── window.ico
├── basic.cc
└── resources.rc
```

`resources.rc`:
```
100 ICON "icons\\application.ico"
32512 ICON "icons\\window.ico"
```

> Note: The ID of the icon resource to be used for the window must be `32512` (`IDI_APPLICATION`).
Compile:
```sh
windres -o build/resources.o resources.rc
g++ basic.cc build/resources.o [...]
```

Remember to bundle the DLLs you have not linked statically, e.g. `WebView2Loader.dll` and those from MinGW-w64.

## Limitations

Expand Down

0 comments on commit c48a9a8

Please sign in to comment.