Comments (1)
This happens because the window demands an owned background brush โ the window itself will delete it, see the hbrBackground
member of WNDCLASSEX
.
In C++, CreateSolidBrush
returns a handle with no safety restrictions, and no concept of ownership. WinSafe adds safety restrictions, with CreateSolidBrush
returning a guard which will delete the brush automatically. So, Rust won't let you pass this guard to the window, otherwise the brush would be deleted twice.
So, you need to give the brush ownership to the window. Just call leak
:
class_bg_brush: gui::Brush::Handle(
unsafe {
HBRUSH::CreateSolidBrush(
winsafe::COLORREF::new(0x0a, 0xba, 0xb5),
).unwrap().leak()
},
),
from winsafe.
Related Issues (20)
- [Question] - Calling windows APIs twice best practice HOT 3
- RegQueryValueEx returning TRANSACTION_REQUEST_NOT_VALID for valid data HOT 6
- nm_custom_draw should provide a mutable reference? HOT 6
- How do you envision WM_USER being used? HOT 1
- `WC::NoValue`? HOT 1
- I don't think `MultiByteToWideChar` and `WideCharToMultiByte` need to add 1 to `num_bytes` HOT 4
- resizable_layout not work as expect HOT 8
- When the new_dlg function is used to create a window, the wm_create event does not work HOT 6
- Async IO should be marked as "unsafe" HOT 1
- CreateToolhelp32Snapshot error when compiling for x86
- Panic in wstring/ QueryFullProcessImageName HOT 3
- How to set up a transparent window๏ผ HOT 1
- please font settings HOT 7
- Add missing API to open app in foreground? HOT 3
- Possible ShellExecuteEx implementation HOT 8
- Linker errors in Windows 7
- Add support for raw-window-handle HOT 3
- Can't run library tests on 0.0.21 HOT 8
- WM_CHAR event does not arrive in custom control HOT 6
- ERROR(0x0078 120) This function is not supported on this system. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winsafe.