Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix window icon on Windows #790

Merged
merged 3 commits into from
Jul 3, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,19 987,19 @@ bool enable_dpi_awareness() {
class win32_edge_engine {
public:
win32_edge_engine(bool debug, void *window) {
enable_dpi_awareness();
if (window == nullptr) {
HINSTANCE hInstance = GetModuleHandle(nullptr);
HICON icon = (HICON)LoadImage(
hInstance, IDI_APPLICATION, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
hInstance, IDI_APPLICATION, IMAGE_ICON, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);

WNDCLASSEXW wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hInstance = hInstance;
wc.lpszClassName = L"webview";
wc.hIcon = icon;
wc.hIconSm = icon;
wc.lpfnWndProc =
(WNDPROC)( [](HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) -> LRESULT {
auto w = (win32_edge_engine *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
Expand Down Expand Up @@ -1043,7 1043,6 @@ class win32_edge_engine {
m_window = *(static_cast<HWND *>(window));
}

enable_dpi_awareness();
ShowWindow(m_window, SW_SHOW);
UpdateWindow(m_window);
SetFocus(m_window);
Expand Down