GithubHelp home page GithubHelp logo

Comments (6)

rodrigocfd avatar rodrigocfd commented on June 10, 2024 1

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 example comctl 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.

Detector-I avatar Detector-I commented on June 10, 2024

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.

Detector-I avatar Detector-I commented on June 10, 2024

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.

rodrigocfd avatar rodrigocfd commented on June 10, 2024

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.

Detector-I avatar Detector-I commented on June 10, 2024

Where did you see this?

I was talking about controls inner data

pub struct ListView(Pin<Arc<Obj>>);

from winsafe.

rodrigocfd avatar rodrigocfd commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.