mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 20:11:29 +11:00
chore: rename wchar_ptr_to_string
to decode_wide
This commit is contained in:
parent
fc7b519b6a
commit
c8dcb40d56
|
@ -1,6 +1,6 @@
|
|||
#![cfg(target_os = "windows")]
|
||||
|
||||
use crate::util::{encode_wide, wchar_ptr_to_string, Counter, LOWORD};
|
||||
use crate::util::{decode_wide, encode_wide, Counter, LOWORD};
|
||||
use windows_sys::Win32::{
|
||||
Foundation::{HWND, LPARAM, LRESULT, WPARAM},
|
||||
UI::{
|
||||
|
@ -72,7 +72,7 @@ impl Submenu {
|
|||
|
||||
unsafe { GetMenuItemInfoW(self.parent_hmenu, self.hmenu as _, false.into(), &mut info) };
|
||||
|
||||
wchar_ptr_to_string(info.dwTypeData)
|
||||
decode_wide(info.dwTypeData)
|
||||
}
|
||||
|
||||
pub fn set_label(&mut self, label: impl AsRef<str>) {
|
||||
|
@ -167,7 +167,7 @@ impl TextMenuItem {
|
|||
|
||||
unsafe { GetMenuItemInfoW(self.parent_hmenu, self.id as _, false.into(), &mut info) };
|
||||
|
||||
wchar_ptr_to_string(info.dwTypeData)
|
||||
decode_wide(info.dwTypeData)
|
||||
.split("\t")
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
|
|
|
@ -31,8 +31,8 @@ pub fn LOWORD(dword: u32) -> u16 {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn wchar_ptr_to_string(wchar: windows_sys::core::PWSTR) -> String {
|
||||
let len = unsafe { windows_sys::Win32::Globalization::lstrlenW(wchar) } as usize;
|
||||
let wchar_slice = unsafe { std::slice::from_raw_parts(wchar, len) };
|
||||
String::from_utf16_lossy(wchar_slice)
|
||||
pub fn decode_wide(w_str: *mut u16) -> String {
|
||||
let len = unsafe { windows_sys::Win32::Globalization::lstrlenW(w_str) } as usize;
|
||||
let w_str_slice = unsafe { std::slice::from_raw_parts(w_str, len) };
|
||||
String::from_utf16_lossy(w_str_slice)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue