use crate::co;
use crate::comctl::privs::*;
use crate::decl::*;
use crate::macros::*;
use crate::msg::*;
use crate::ole::privs::*;
use crate::prelude::*;
use crate::user::privs::*;
pub struct TbAddBitmap<'a> {
pub num_images: u32,
pub info: &'a TBADDBITMAP,
}
impl<'a> MsgSend for TbAddBitmap<'a> {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ADDBITMAP.into(),
wparam: self.num_images as _,
lparam: self.info as *const _ as _,
}
}
}
pub struct TbAddButtons<'a, 'b> {
pub buttons: &'a mut [TBBUTTON<'b>],
}
impl<'a, 'b> MsgSend for TbAddButtons<'a, 'b> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ADDBUTTONS.into(),
wparam: self.buttons.len() as _,
lparam: self.buttons.as_mut_ptr() as _,
}
}
}
pub struct TbAddString {
pub texts: ResStrs,
}
impl MsgSend for TbAddString {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ADDSTRING.into(),
wparam: match &self.texts {
ResStrs::Res(_, hinst) => hinst.ptr() as _,
ResStrs::Strs(_) => 0,
},
lparam: match &self.texts {
ResStrs::Res(res, _) => res.as_ptr() as _,
ResStrs::Strs(strs) => strs.as_ptr() as _,
},
}
}
}
pub_struct_msg_empty! { TbAutoSize: co::TBM::AUTOSIZE.into();
}
pub struct TbButtonCount {}
impl MsgSend for TbButtonCount {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::BUTTONCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbButtonStructSize {
pub size: u32,
}
impl MsgSend for TbButtonStructSize {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::BUTTONSTRUCTSIZE.into(),
wparam: self.size as _,
lparam: 0,
}
}
}
pub struct TbChangeBitmap {
pub btn_cmd_id: u16,
pub image: IdxCbNone,
}
impl MsgSend for TbChangeBitmap {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::CHANGEBITMAP.into(),
wparam: self.btn_cmd_id as _,
lparam: self.image.into(),
}
}
}
pub struct TbCheckButton {
pub btn_cmd_id: u16,
pub check: bool,
}
impl MsgSend for TbCheckButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::CHECKBUTTON.into(),
wparam: self.btn_cmd_id as _,
lparam: self.check as _,
}
}
}
pub struct TbCommandToIndex {
pub btn_cmd_id: u16,
}
impl MsgSend for TbCommandToIndex {
type RetType = Option<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::COMMANDTOINDEX.into(),
wparam: self.btn_cmd_id as _,
lparam: 0,
}
}
}
pub_struct_msg_empty! { TbCustomize: co::TBM::CUSTOMIZE.into();
}
pub struct TbDeleteButton {
pub btn_index: u32,
}
impl MsgSend for TbDeleteButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::CHECKBUTTON.into(),
wparam: self.btn_index as _,
lparam: 0,
}
}
}
pub struct TbEnableButton {
pub btn_cmd_id: u16,
pub enable: bool,
}
impl MsgSend for TbEnableButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ENABLEBUTTON.into(),
wparam: self.btn_cmd_id as _,
lparam: self.enable as _,
}
}
}
pub struct TbGetAnchorHighlight {}
impl MsgSend for TbGetAnchorHighlight {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETANCHORHIGHLIGHT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetBitmap {
pub btn_cmd_id: u16,
}
impl MsgSend for TbGetBitmap {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBITMAP.into(),
wparam: self.btn_cmd_id as _,
lparam: 0,
}
}
}
pub struct TbGetBitmapFlags {}
impl MsgSend for TbGetBitmapFlags {
type RetType = co::TBBF;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBBF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBITMAPFLAGS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetButton<'a, 'b> {
pub btn_index: u32,
pub info: &'a mut TBBUTTON<'b>,
}
impl<'a, 'b> MsgSend for TbGetButton<'a, 'b> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBUTTON.into(),
wparam: self.btn_index as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct TbGetButtonInfo<'a, 'b> {
pub btn_cmd_id: u16,
pub info: &'a mut TBBUTTONINFO<'b>,
}
impl<'a, 'b> MsgSend for TbGetButtonInfo<'a, 'b> {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBUTTONINFO.into(),
wparam: self.btn_cmd_id as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct TbGetButtonSize {}
impl MsgSend for TbGetButtonSize {
type RetType = SIZE;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
SIZE::from(v as u32)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBUTTONSIZE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetButtonText<'a> {
pub btn_cmd_id: u16,
pub text: &'a mut WString,
}
impl<'a> MsgSend for TbGetButtonText<'a> {
type RetType = SysResult<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETBUTTONTEXT.into(),
wparam: self.btn_cmd_id as _,
lparam: unsafe { self.text.as_mut_ptr() } as _,
}
}
}
pub struct TbGetColorScheme<'a> {
pub scheme: &'a mut COLORSCHEME,
}
impl<'a> MsgSend for TbGetColorScheme<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETCOLORSCHEME.into(),
wparam: 0,
lparam: self.scheme as *mut _ as _,
}
}
}
pub struct TbGetDisabledImageList {}
impl MsgSend for TbGetDisabledImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETDISABLEDIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetExtendedStyle {}
impl MsgSend for TbGetExtendedStyle {
type RetType = co::TBSTYLE_EX;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBSTYLE_EX::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETEXTENDEDSTYLE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetHotImageList {}
impl MsgSend for TbGetHotImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETHOTIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetHotItem {}
impl MsgSend for TbGetHotItem {
type RetType = Option<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETHOTITEM.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetIdealSize<'a> {
pub get_height: bool,
pub size: &'a mut SIZE,
}
impl<'a> MsgSend for TbGetIdealSize<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETIDEALSIZE.into(),
wparam: self.get_height as _,
lparam: self.size as *mut _ as _,
}
}
}
pub struct TbGetImageList {}
impl MsgSend for TbGetImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetImageListCount {}
impl MsgSend for TbGetImageListCount {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETIMAGELISTCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetInsertMark<'a> {
pub info: &'a mut TBINSERTMARK,
}
impl<'a> MsgSend for TbGetInsertMark<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETINSERTMARK.into(),
wparam: 0,
lparam: self.info as *mut _ as _,
}
}
}
pub struct TbGetInsertMarkColor {}
impl MsgSend for TbGetInsertMarkColor {
type RetType = COLORREF;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetItemDropdownRect<'a> {
pub item_index: u32,
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for TbGetItemDropdownRect<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETITEMDROPDOWNRECT.into(),
wparam: self.item_index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct TbGetItemRect<'a> {
pub btn_index: u32,
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for TbGetItemRect<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETITEMRECT.into(),
wparam: self.btn_index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct TbGetMaxSize<'a> {
pub size: &'a mut SIZE,
}
impl<'a> MsgSend for TbGetMaxSize<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETMAXSIZE.into(),
wparam: 0,
lparam: self.size as *mut _ as _,
}
}
}
pub struct TbGetMetrics<'a> {
pub metrics: &'a mut TBMETRICS,
}
impl<'a> MsgSend for TbGetMetrics<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETMETRICS.into(),
wparam: 0,
lparam: self.metrics as *mut _ as _,
}
}
}
pub struct TbGetObject<'a> {
pub obj: &'a IDropTarget,
}
impl<'a> MsgSend for TbGetObject<'a> {
type RetType = HrResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
HrRet(v as _).to_hrresult()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETOBJECT.into(),
wparam: &IDropTarget::IID as *const _ as _,
lparam: &self.obj.ptr() as *const _ as _,
}
}
}
pub struct TbGetPadding {}
impl MsgSend for TbGetPadding {
type RetType = (u16, u16);
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _), HIWORD(v as _))
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETPADDING.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetPressedImageList {}
impl MsgSend for TbGetPressedImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETPRESSEDIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetRect<'a> {
pub cmd_id: u16,
pub rect: &'a mut RECT,
}
impl<'a> MsgSend for TbGetRect<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETRECT.into(),
wparam: self.cmd_id as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct TbGetRows {}
impl MsgSend for TbGetRows {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETROWS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetState {
pub cmd_id: u16,
}
impl MsgSend for TbGetState {
type RetType = SysResult<co::TBSTATE>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| unsafe { co::TBSTATE::from_raw(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETSTATE.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbGetString<'a> {
pub index: u16,
pub text: &'a mut WString,
}
impl<'a> MsgSend for TbGetString<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETSTRING.into(),
wparam: MAKEDWORD(self.text.buf_len() as _, self.index) as _,
lparam: unsafe { self.text.as_mut_ptr() } as _,
}
}
}
pub struct TbGetStyle {}
impl MsgSend for TbGetStyle {
type RetType = co::BTNS;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { co::BTNS::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETSTYLE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetTextRows {}
impl MsgSend for TbGetTextRows {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETTEXTROWS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetTooltips {}
impl MsgSend for TbGetTooltips {
type RetType = Option<HWND>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HWND::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETTOOLTIPS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbGetUnicodeFormat {}
impl MsgSend for TbGetUnicodeFormat {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::GETUNICODEFORMAT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct TbHideButton {
pub cmd_id: u16,
pub hide: bool,
}
impl MsgSend for TbHideButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::HIDEBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.hide as _, 0) as _,
}
}
}
pub struct TbHitTest<'a> {
pub coords: &'a mut POINT,
}
impl<'a> MsgSend for TbHitTest<'a> {
type RetType = i32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::HITTEST.into(),
wparam: 0,
lparam: self.coords as *mut _ as _,
}
}
}
pub struct TbIndeterminate {
pub cmd_id: u16,
pub indeterminate: bool,
}
impl MsgSend for TbIndeterminate {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::INDETERMINATE.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.indeterminate as _, 0) as _,
}
}
}
pub struct TbInsertButton<'a, 'b> {
pub index: u32,
pub button: &'a TBBUTTON<'b>,
}
impl<'a, 'b> MsgSend for TbInsertButton<'a, 'b> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::INSERTBUTTON.into(),
wparam: self.index as _,
lparam: self.button as *const _ as _,
}
}
}
pub struct TbInsertMarkHitTest<'a, 'b> {
pub coords: &'a POINT,
pub info: &'b mut TBINSERTMARK,
}
impl<'a, 'b> MsgSend for TbInsertMarkHitTest<'a, 'b> {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::INSERTMARKHITTEST.into(),
wparam: self.coords as *const _ as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct TbIsButtonChecked {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonChecked {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONCHECKED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbIsButtonEnabled {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonEnabled {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONENABLED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbIsButtonHidden {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonHidden {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONHIDDEN.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbIsButtonHighlighted {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonHighlighted {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONHIGHLIGHTED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbIsButtonIndeterminate {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonIndeterminate {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONINDETERMINATE.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbIsButtonPressed {
pub cmd_id: u16,
}
impl MsgSend for TbIsButtonPressed {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::ISBUTTONPRESSED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct TbLoadImages {
pub img_list: co::IDB,
}
impl MsgSend for TbLoadImages {
type RetType = u32;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::LOADIMAGES.into(),
wparam: self.img_list.raw() as _,
lparam: HINST_COMMCTRL,
}
}
}
pub struct TbMapAccelerator<'a> {
pub character: char,
pub cmd_id: &'a mut u16,
}
impl<'a> MsgSend for TbMapAccelerator<'a> {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::MAPACCELERATOR.into(),
wparam: self.character as _,
lparam: self.cmd_id as *mut _ as _,
}
}
}
pub struct TbMarkButton {
pub cmd_id: u16,
pub highlight: bool,
}
impl MsgSend for TbMarkButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::MARKBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.highlight as _, 0) as _,
}
}
}
pub struct TbMoveButton {
pub btn_index: u32,
pub dest_index: u32,
}
impl MsgSend for TbMoveButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::MOVEBUTTON.into(),
wparam: self.btn_index as _,
lparam: self.dest_index as _,
}
}
}
pub struct TbPressButton {
pub cmd_id: u16,
pub press: bool,
}
impl MsgSend for TbPressButton {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::PRESSBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.press as _, 0) as _,
}
}
}
pub struct TbReplaceBitmap<'a> {
pub info: &'a TBREPLACEBITMAP,
}
impl<'a> MsgSend for TbReplaceBitmap<'a> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::REPLACEBITMAP.into(),
wparam: 0,
lparam: self.info as *const _ as _,
}
}
}
pub struct TbSetAnchorHighlight {
pub enable: bool,
}
impl MsgSend for TbSetAnchorHighlight {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETANCHORHIGHLIGHT.into(),
wparam: self.enable as _,
lparam: 0,
}
}
}
pub struct TbSetBitmapSize {
pub width: u16,
pub height: u16,
}
impl MsgSend for TbSetBitmapSize {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETBITMAPSIZE.into(),
wparam: 0,
lparam: MAKEDWORD(self.width, self.height) as _,
}
}
}
pub struct TbSetButtonInfo<'a, 'b> {
pub btn_cmd_id: u16,
pub info: &'b TBBUTTONINFO<'a>,
}
impl<'a, 'b> MsgSend for TbSetButtonInfo<'a, 'b> {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETBUTTONINFO.into(),
wparam: self.btn_cmd_id as _,
lparam: self.info as *const _ as _,
}
}
}
pub struct TbSetButtonSize {
pub width: u16,
pub height: u16,
}
impl MsgSend for TbSetButtonSize {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETBUTTONSIZE.into(),
wparam: 0,
lparam: MAKEDWORD(self.width, self.height) as _,
}
}
}
pub struct TbSetButtonWidth {
pub min_width: u16,
pub max_width: u16,
}
impl MsgSend for TbSetButtonWidth {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETBUTTONWIDTH.into(),
wparam: 0,
lparam: MAKEDWORD(self.min_width, self.max_width) as _,
}
}
}
pub struct TbSetCmdId {
pub btn_index: u32,
pub cmd_id: u16,
}
impl MsgSend for TbSetCmdId {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETCMDID.into(),
wparam: self.btn_index as _,
lparam: self.cmd_id as _,
}
}
}
pub struct TbSetColorScheme<'a> {
pub scheme: &'a COLORSCHEME,
}
impl<'a> MsgSend for TbSetColorScheme<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETCOLORSCHEME.into(),
wparam: 0,
lparam: self.scheme as *const _ as _,
}
}
}
pub struct TbSetDisabledImageList<'a> {
pub himagelist: &'a HIMAGELIST,
}
impl<'a> MsgSend for TbSetDisabledImageList<'a> {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETDISABLEDIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct TbSetDrawTextFlags {
pub mask: co::DT,
pub draw: co::DT,
}
impl MsgSend for TbSetDrawTextFlags {
type RetType = co::DT;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { co::DT::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETDRAWTEXTFLAGS.into(),
wparam: self.mask.raw() as _,
lparam: self.draw.raw() as _,
}
}
}
pub struct TbSetExtendedStyle {
pub style: co::TBSTYLE_EX,
}
impl MsgSend for TbSetExtendedStyle {
type RetType = co::TBSTYLE_EX;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBSTYLE_EX::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETEXTENDEDSTYLE.into(),
wparam: 0,
lparam: self.style.raw() as _,
}
}
}
pub struct TbSetHotImageList<'a> {
pub himagelist: &'a HIMAGELIST,
}
impl<'a> MsgSend for TbSetHotImageList<'a> {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETHOTIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct TbSetHotItem {
pub index: Option<u32>,
}
impl MsgSend for TbSetHotItem {
type RetType = Option<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|idx| idx as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETHOTITEM.into(),
wparam: self.index.map_or(-1, |idx| idx as i32) as _,
lparam: 0,
}
}
}
pub struct TbSetHotItem2 {
pub index: Option<u32>,
pub flags: co::HICF,
}
impl MsgSend for TbSetHotItem2 {
type RetType = Option<u32>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|idx| idx as _)
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETHOTITEM2.into(),
wparam: self.index.map_or(-1, |idx| idx as i32) as _,
lparam: self.flags.raw() as _,
}
}
}
pub struct TbSetImageList {
pub himagelist: HIMAGELIST,
}
impl MsgSend for TbSetImageList {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct TbSetIndent {
pub pixels: u32,
}
impl MsgSend for TbSetIndent {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETINDENT.into(),
wparam: self.pixels as _,
lparam: 0,
}
}
}
pub struct TbSetInsertMark<'a> {
pub info: &'a TBINSERTMARK,
}
impl<'a> MsgSend for TbSetInsertMark<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETINSERTMARK.into(),
wparam: 0,
lparam: self.info as *const _ as _,
}
}
}
pub struct TbSetInsertMarkColor {
pub color: COLORREF,
}
impl MsgSend for TbSetInsertMarkColor {
type RetType = COLORREF;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: u32::from(self.color) as _,
}
}
}
pub struct TbSetListGap {
pub gap: u32,
}
impl MsgSend for TbSetListGap {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETLISTGAP.into(),
wparam: self.gap as _,
lparam: 0,
}
}
}
pub struct TbSetMaxTextRows {
pub max_rows: u32,
}
impl MsgSend for TbSetMaxTextRows {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETMAXTEXTROWS.into(),
wparam: self.max_rows as _,
lparam: 0,
}
}
}
pub struct TbSetMetrics<'a> {
pub metrics: &'a TBMETRICS,
}
impl<'a> MsgSend for TbSetMetrics<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETMETRICS.into(),
wparam: 0,
lparam: self.metrics as *const _ as _,
}
}
}
pub struct TbSetPadding {
pub horizontal: u16,
pub vertical: u16,
}
impl MsgSend for TbSetPadding {
type RetType = (u16, u16);
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _), HIWORD(v as _))
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETPADDING.into(),
wparam: 0,
lparam: MAKEDWORD(self.horizontal, self.vertical) as _,
}
}
}
pub struct TbSetParent<'a> {
pub hparent: &'a HWND,
}
impl<'a> MsgSend for TbSetParent<'a> {
type RetType = Option<HWND>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HWND::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETPARENT.into(),
wparam: 0,
lparam: self.hparent.ptr() as _,
}
}
}
pub struct TbSetPressedImageList<'a> {
pub index: u32,
pub himagelist: Option<&'a HIMAGELIST>,
}
impl<'a> MsgSend for TbSetPressedImageList<'a> {
type RetType = Option<HIMAGELIST>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETPRESSEDIMAGELIST.into(),
wparam: self.index as _,
lparam: self.himagelist.map_or(0, |h| h.ptr() as _),
}
}
}
pub struct TbSetRows<'a> {
pub num_rows: u16,
pub create_more: bool,
pub bounds: &'a mut RECT,
}
impl<'a> MsgSend for TbSetRows<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETROWS.into(),
wparam: MAKEDWORD(self.num_rows, self.create_more as _) as _,
lparam: self.bounds as *mut _ as _,
}
}
}
pub struct TbSetState {
pub btn_cmd_id: u16,
pub state: co::BTNS,
}
impl MsgSend for TbSetState {
type RetType = SysResult<()>;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETSTATE.into(),
wparam: self.btn_cmd_id as _,
lparam: MAKEDWORD(self.state.raw() as _, 0) as _,
}
}
}
pub struct TbSetStyle {
pub style: co::BTNS,
}
impl MsgSend for TbSetStyle {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETSTYLE.into(),
wparam: 0,
lparam: self.style.raw() as _,
}
}
}
pub struct TbSetTooltips<'a> {
pub htooltips: Option<&'a HWND>,
}
impl<'a> MsgSend for TbSetTooltips<'a> {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETTOOLTIPS.into(),
wparam: self.htooltips.map_or(0, |h| h.ptr() as _),
lparam: 0,
}
}
}
pub struct TbSetUnicodeFormat {
pub use_unicode: bool,
}
impl MsgSend for TbSetUnicodeFormat {
type RetType = bool;
unsafe fn isize_to_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETUNICODEFORMAT.into(),
wparam: self.use_unicode as _,
lparam: 0,
}
}
}
pub struct TbSetWindowTheme {
pub visual_style: WString,
}
impl MsgSend for TbSetWindowTheme {
type RetType = ();
unsafe fn isize_to_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> Wm {
Wm {
msg_id: co::TBM::SETWINDOWTHEME.into(),
wparam: 0,
lparam: self.visual_style.as_ptr() as _,
}
}
}