#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::prelude::*;
use crate::shell::ffi;
impl shell_Hwnd for HWND {}
pub trait shell_Hwnd: ole_Hwnd {
fn DragAcceptFiles(&self, accept: bool) {
unsafe { ffi::DragAcceptFiles(self.ptr(), accept as _); }
}
fn ShellAbout(&self,
title_bar: &str,
first_line: Option<&str>,
other_stuff: Option<&str>,
hicon: Option<&HICON>,
) -> SysResult<()>
{
bool_to_sysresult(
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()),
)
},
)
}
fn ShellExecute(&self,
operation: &str,
file: &str,
parameters: Option<&str>,
directory: Option<&str>,
show_cmd: co::SW,
) -> Result<HINSTANCE, co::SE_ERR>
{
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(),
)
};
unsafe {
if ret <= 32 as _ {
Err(co::SE_ERR::from_raw(ret as _))
} else {
Ok(HINSTANCE::from_ptr(ret as _))
}
}
}
}