#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::shell::ffi;
impl HWND {
pub fn DragAcceptFiles(&self, accept: bool) {
unsafe {
ffi::DragAcceptFiles(self.ptr(), accept as _);
}
}
pub fn ShellAbout(
&self,
title_bar: &str,
first_line: Option<&str>,
other_stuff: Option<&str>,
hicon: Option<&HICON>,
) -> SysResult<()> {
BoolRet(unsafe {
ffi::ShellAboutW(
self.ptr(),
WString::from_str(&match first_line {
Some(line) => format!("{}#{}", title_bar, line),
None => title_bar.to_owned(),
})
.as_ptr(),
WString::from_opt_str(other_stuff).as_ptr(),
hicon.map_or(std::ptr::null_mut(), |h| h.ptr()),
)
})
.to_sysresult()
}
pub fn ShellExecute(
&self,
operation: &str,
file: &str,
parameters: Option<&str>,
directory: Option<&str>,
show_cmd: co::SW,
) -> SysResult<()> {
let ret = unsafe {
ffi::ShellExecuteW(
self.ptr(),
WString::from_str(operation).as_ptr(),
WString::from_str(file).as_ptr(),
parameters.map_or(std::ptr::null(), |lp| WString::from_str(lp).as_ptr()),
directory.map_or(std::ptr::null(), |lp| WString::from_str(lp).as_ptr()),
show_cmd.raw(),
)
};
if ret as usize > 32 { Ok(()) } else { Err(GetLastError()) }
}
}