println in winmain

This commit is contained in:
rustdesk
2023-07-08 12:34:40 +08:00
parent 685d960b1e
commit afd77181ff
3 changed files with 42 additions and 5 deletions

View File

@@ -48,7 +48,7 @@ pub fn breakdown_callback() {
pub fn change_resolution(name: &str, width: usize, height: usize) -> ResultType<()> {
let cur_resolution = current_resolution(name)?;
// For MacOS
// to-do: Make sure the following comparison works.
// to-do: Make sure the following comparison works.
// For Linux
// Just run "xrandr", dpi may not be taken into consideration.
// For Windows

View File

@@ -2297,3 +2297,26 @@ mod tests {
assert_eq!(chr, None)
}
}
pub fn message_box(text: &str) {
let mut text = text.to_owned();
if !text.ends_with("!") {
use arboard::Clipboard as ClipboardContext;
match ClipboardContext::new() {
Ok(mut ctx) => {
ctx.set_text(&text).ok();
text = format!("{}\n\nAbove text has been copied to clipboard", &text);
}
_ => {}
}
}
let text = text
.encode_utf16()
.chain(std::iter::once(0))
.collect::<Vec<u16>>();
let caption = "RustDesk Output"
.encode_utf16()
.chain(std::iter::once(0))
.collect::<Vec<u16>>();
unsafe { MessageBoxW(std::ptr::null_mut(), text.as_ptr(), caption.as_ptr(), MB_OK) };
}