Comments (6)
It seems you are correct, NMLVCUSTOMDRAW
should me mutable. Let me know if it's working for you now.
I'm unsure about all other nm_custom_draw
being mutable, though.
from winsafe.
That was fast, thank you @rodrigocfd !
I can confirm, it works as expected.
One note: I needed to assign the colors this way:
let txt_clr = COLORREF::new(highlight.fg_color.0, highlight.fg_color.1, highlight.fg_color.2);
unsafe {
*draw.clrText.as_mut() = txt_clr.raw();
}
If i do it any other way the compiler optimizes it away in release mode 🤷. But i assume that's a skill issue on my side.
from winsafe.
Won't this work for you?
self.lst_entries.on().nm_custom_draw(|p| {
let blue = w::COLORREF::new(0x00, 0x00, 0xff);
p.clrText = blue; // simple assignment!
// ...
Ok(co::CDRF::DODEFAULT)
});
from winsafe.
Unfortunately not.
I made a quick repo reproducing the behavior if you want to try it out.
Do you have any ideas what is happening here?
This is a learning project for me, so it's not a problem if i have to use unsafe.
But it would be nice to understand what exactly is going on here.
Edit: Added a profile with lto to the repo. This removes all colors, even the unsafe version doesn't work.
from winsafe.
The root cause was way deeper than the message handling itself. The lambda parameter was originally const, then later cast to mutable, thus causing undefined behavior.This is a rule that comes from C++, which I fortunately already faced in my C++ days.
I still don't know how this change will propagate throughout all WM_NOTIFY events, but so far everything seems fine.
Your example is working for me with all profiles now. Let me know if it works for you.
from winsafe.
I've done some small testing with max optimizations enabled.
So far everything works fine. Thank you so much for the support!
Also thanks for the info. I checked your changes and the stackoverflow post you linked.
This makes sense to me now.
I still have a bunch of features to implement, so i keep an eye out for anything suspicious.
from winsafe.
Related Issues (20)
- winsvc.h HOT 2
- validate_retrieved_reg_val always fails
- [Question] - Calling windows APIs twice best practice HOT 3
- RegQueryValueEx returning TRANSACTION_REQUEST_NOT_VALID for valid data 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
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.