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

Use custom application icon on Windows, if present. #2274

Merged
merged 3 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ values and their textual representations. ([#1377])
- All Image formats are now optional, reducing compile time and binary size by default ([#1340] by [@JAicewizard])
- The `Cursor` API has changed to a stateful one ([#1433] by [@jneem])
- Part of the `SAVE_FILE` command is now `SAVE_FILE_AS` ([#1463] by [@jneem])
- Windows: Use custom application icon, if present ([#2274] by [@tay64])

### Deprecated
- Parse widget (replaced with `Formatter` trait) ([#1377] by [@cmyr])
Expand Down Expand Up @@ -864,7 +865,9 @@ Last release without a changelog :(
[#2203]: https://github.com/linebender/druid/pull/2203
[#2235]: https://github.com/linebender/druid/pull/2235
[#2247]: https://github.com/linebender/druid/pull/2247
[#2274]: https://github.com/linebender/druid/pull/2274
[#2284]: https://github.com/linebender/druid/pull/2284

[Unreleased]: https://github.com/linebender/druid/compare/v0.7.0...master
[0.7.0]: https://github.com/linebender/druid/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
5 changes: 3 additions & 2 deletions druid-shell/src/backend/windows/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ use winapi::shared::ntdef::LPCWSTR;
use winapi::shared::windef::{DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, HCURSOR, HWND};
use winapi::shared::winerror::HRESULT_FROM_WIN32;
use winapi::um::errhandlingapi::GetLastError;
use winapi::um::libloaderapi::GetModuleHandleW;
use winapi::um::shellscalingapi::PROCESS_PER_MONITOR_DPI_AWARE;
use winapi::um::winnls::GetUserDefaultLocaleName;
use winapi::um::winnt::LOCALE_NAME_MAX_LENGTH;
use winapi::um::winuser::{
DispatchMessageW, GetAncestor, GetMessageW, LoadIconW, PeekMessageW, PostMessageW,
PostQuitMessage, RegisterClassW, TranslateAcceleratorW, TranslateMessage, GA_ROOT,
IDI_APPLICATION, MSG, PM_NOREMOVE, WM_TIMER, WNDCLASSW,
MAKEINTRESOURCEW, MSG, PM_NOREMOVE, WM_TIMER, WNDCLASSW,
};

use piet_common::D2DLoadedFonts;
Expand Down Expand Up @@ -90,7 +91,7 @@ impl Application {
.is_ok()
{
let class_name = CLASS_NAME.to_wide();
let icon = unsafe { LoadIconW(0 as HINSTANCE, IDI_APPLICATION) };
let icon = unsafe { LoadIconW(GetModuleHandleW(0 as LPCWSTR), MAKEINTRESOURCEW(1)) };
let wnd = WNDCLASSW {
style: 0,
lpfnWndProc: Some(window::win_proc_dispatch),
Expand Down