Let class_name = to_wstring( " my_window") Then, we call the init_interface function to create our calculator's interface (static and buttons). Here, we register and create our main window. This is the entry point function of our program. X, y, 40, 86, h_wnd, btn_num_id as HMENU, 0 as HINSTANCE, std::ptr::null_mut()) " =".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, " %".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, " C".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, " /".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, " x".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, " -".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, X, y, 40, 32, h_wnd, btn_num_id as HMENU, 0 as HINSTANCE, std::ptr::null_mut()) " +".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, X, y, 148, 32, h_wnd, btn_num_id as HMENU, 0 as HINSTANCE, std::ptr::null_mut()) " 0".as_ptr() as *mut _, WS_CHILD | WS_VISIBLE, User32::CreateWindowExA( 0, " Button".as_ptr() as *mut _, And also, we will see how we can handle a button's click event and change label control's background color.įirst, we have to extern our necessary crates (these crates are available on the internet): to design an application's user interface. So this tip will help you to understand the use of basic graphical elements such as buttons, labels, etc. But at the end, it helps a lot to understand the basic concept. Using the Codeĭesigning graphical user interface using pure Win32 API is a little hard.
#Rust console calculator code#
Although there were some mistakes, some Code Project members helped me through comments to correct those mistakes.
![rust console calculator rust console calculator](https://www.boatvana.com/files/04-2022/ad12264/2016-carolina-skiff-198-dlv-222859936__large.jpg)
![rust console calculator rust console calculator](https://rusttips.com/wp-content/uploads/2021/04/rust-useful-keybinds-commands-220x160.jpg)
In Code Project, I wrote an article on Rust called 'Win32 GUI Programming In Rust Language ' where I showed how we can create a simple window using pure Win32 API. Here in this tip, we will design a simple calculator's graphical interface using pure Win32 API functions in Rust programming language.