Comments (6)
the only problem that I find with it so far is its not so WINAPI beginner friendly...
WinSafe was never meant to be easier. It's meant to be a Rust binding safer than winapi and windows crates, which are wildly unsafe – basically writing C in Rust.
The problem here is, if you can't write WinAPI code in C, you certainly can't write in Rust either. So, if you're a beginner, I strongly suggest you to study the WinAPI in C. Once you learn the concepts, WinSafe will be a piece of cake for you, because you'll be surrounded by a lot of guardrails.
I mean the
gui
feature is good and straight forward, but if you want to use any other feature like for examplecomctl
it become so complex...
I'm glad you like the gui
module.
The gui
module is just a thin layer over the window creation/handling, because it's very tedious to write it, and you end up rewriting the same thing over and over again. So I gathered all the stuff together. Plus, lots of corner cases and dirty tricks are properly handled.
I mean I can't figure out how can I create a simple UpDown/Spin control, checking the original Microsoft documentation wont help either because how winsafe work is kinda different...
It is not different at all. If you can create any control in C, you can create it in Rust with WinSafe. Here you have an example of how to create a Tab control from scratch.
overall It will be very good if it were possible to reduce complexity a little...
btw as I said atm I'm trying to create a UpDown/Spin control but I can't figure it out, can you please help a little about it?
As you already noticed, I already implemented many native controls in the gui
module. I plan to implement all of them. I'll take a look at the UpDown, and I'll do my best to add it to the collection. I'll leave this issue open until I get it (soon, I hope).
Thank you for the UpDown control suggestion.
from winsafe.
thank you for fast respond
WinSafe was never meant to be easier. It's meant to be a Rust binding safer than winapi and windows crates, which are wildly unsafe – basically writing C in Rust.
oh is that so... my first look at winsafe library was gui
and because it was very easy to start working with I kinda expected to have same experience with other features as well... but looks like not, currently its still same API with a little changes most of the times...
I hope to someday see more good and easy to use codes like what we currently have in gui
.
It is not different at all. If you can create any control in C, you can create it in Rust with WinSafe. Here you have an example of how to create a Tab control from scratch.
thank you, I checked it and now things are a little more clear to me on how to manually do things... its not as easy, but it get the job done...
At the end thank you for all your works.
from winsafe.
One anther thing I noticed
when a control will be drop? when the parent dropped?
I'm asking because if I make something and it goes out of scoop it wont get deleted, so Im wondering maybe it relay on parent?
and one last thing, why you wrap everything into Arc
? I mean Im not complaining it make working with them a lot easier but why?
from winsafe.
One anther thing I noticed when a control will be drop? when the parent dropped? I'm asking because if I make something and it goes out of scoop it wont get deleted, so Im wondering maybe it relay on parent?
Usually you'll have your control as a field of the same struct which has the window itself, like:
pub struct MyWindow {
wnd: gui::WindowMain,
btn: gui::Button,
}
And then something like:
fn main() {
let my_window = MyWindow::new();
my_window.run_main(None);
}
So the control will go out of scope together with my_window
.
and one last thing, why you wrap everything into
Arc
? I mean Im not complaining it make working with them a lot easier but why?
Where did you see this?
from winsafe.
Where did you see this?
I was talking about controls inner data
pub struct ListView(Pin<Arc<Obj>>);
from winsafe.
Because the controls must be cloned into closures to be accessed (all events are handled with closures), and WinSafe offers support to multithreading. So using Arc
was not a choice, but a necessity.
from winsafe.
Related Issues (20)
- WindowModal::show_modal never returns
- as_mut may be unsound HOT 1
- ListBox:: new() ListBoxOpts list_box_style field ignores co::WS::HSCROLL flag when present HOT 3
- Custom color on for class_bg_brush on WindowMainOpts HOT 1
- ...Guard::new should be unsafe and leak should not be HOT 2
- Question concerning creating a DC, getting a ListBox's selected font, and invoking GetSystemMetrics(SM_SM_CXBORDER) HOT 2
- code panics on adding root to treeview HOT 1
- Add EnableScrollBar function
- How to Custom msg_id ? HOT 1
- How to close a process? HOT 7
- How to pass a RECT as a parameter in MapWindowPoints? HOT 4
- FindWindow always encounters an error HOT 2
- Missing StretchDIBits from Windows GDI HOT 2
- Use microsoft windows-rs crate? HOT 2
- Add `GetVolumePathName` function HOT 2
- Linker error when calling DrawText() HOT 1
- Running a FileSaveAs dialog crashes HOT 2
- Wrong GetAsyncKeyState return type. HOT 4
- SetLayeredWindowAttributes HOT 3
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.