fn hook_tabs(&self) {
        use crate::bind_raw_event_handler_inner;
        use winapi::shared::minwindef::{HIWORD, LOWORD};
        use winapi::um::winuser::{NMHDR, WM_SIZE, WM_NOTIFY};
        use winapi::um::commctrl::{TCM_GETCURSEL, TCN_SELCHANGE};
        use winapi::um::winuser::SendMessageW;

        if self.handle.blank() { panic!("{}", NOT_BOUND); }
        let handle = self.handle.hwnd().expect(BAD_HANDLE);

        let parent_handle_raw = wh::get_window_parent(handle);
        let parent_handle = ControlHandle::Hwnd(parent_handle_raw);
       
        let handler0 = bind_raw_event_handler_inner(&parent_handle, handle as usize, move |_hwnd, msg, _w, l| { unsafe {
            match msg {
                WM_NOTIFY => {
                    let nmhdr: &NMHDR = mem::transmute(l);
                    if nmhdr.code == TCN_SELCHANGE {
                        let index = SendMessageW(handle, TCM_GETCURSEL, 0, 0) as i32;
                        let data: (HWND, i32) = (handle, index);
                        let data_ptr = &data as *const (HWND, i32);
                        EnumChildWindows(handle, Some(toggle_children_tabs), data_ptr as LPARAM);
                    }
                },
                _ => {}
            }

            None
        } });

        let handler1 = bind_raw_event_handler_inner(&self.handle, handle as usize, move |hwnd, msg, _w, l| { unsafe {
            match msg {
                WM_SIZE => {
                    use winapi::shared::windef::{RECT, HGDIOBJ};
                    use winapi::um::winuser::{GetDC, DrawTextW, ReleaseDC, DT_CALCRECT, DT_LEFT};
                    use winapi::um::wingdi::SelectObject;

                    let size = l as u32;
                    let width = LOWORD(size) as i32;
                    let height = HIWORD(size) as i32;
                    let (w, h) = crate::win32::high_dpi::physical_to_logical(width, height);

                    let mut data = ResizeDirectChildrenParams {
                        parent: hwnd,
                        width: w as u32,
                        height: h as u32,
                        tab_offset_y: 0
                    };

                    // Get the height of the tabs
                    let font_handle = wh::get_window_font(hwnd);
                    let mut r: RECT = mem::zeroed();
                    let dc = GetDC(hwnd);
                    let old = SelectObject(dc, font_handle as HGDIOBJ);
                    let calc: [u16;2] = [75, 121];
                    DrawTextW(dc, calc.as_ptr(), 2, &mut r, DT_CALCRECT | DT_LEFT);
                    SelectObject(dc, old);
                    ReleaseDC(hwnd, dc);

                    // Fix the width/height of the tabs
                    const BORDER_SIZE: u32 = 11;
                    let tab_height = r.bottom as u32 + BORDER_SIZE;
                    if data.width > BORDER_SIZE { data.width -= BORDER_SIZE; }
                    if data.height > tab_height { 
                        data.height -= (tab_height + BORDER_SIZE).min(data.height);
                    }
                    data.tab_offset_y = tab_height;
                    
                    let data_ptr = &data as *const ResizeDirectChildrenParams;
                    EnumChildWindows(hwnd, Some(resize_direct_children), mem::transmute(data_ptr));
                },
                _ => {}
            }

            None
        } } );

        *self.handler0.borrow_mut() = Some(handler0.unwrap());
        *self.handler1.borrow_mut() = Some(handler1.unwrap());
    }
/// The tab widget lacks basic functionalities on it's own. This fix it. 
The tab widget lacks basic functionalities on it's own. This fix it.
The tab widget lacks basic functionalities on it ' s own . This fix it .
fn hook_tabs(&self) {
        use crate::bind_raw_event_handler_inner;
        use winapi::shared::minwindef::{HIWORD, LOWORD};
        use winapi::um::winuser::{NMHDR, WM_SIZE, WM_NOTIFY};
        use winapi::um::commctrl::{TCM_GETCURSEL, TCN_SELCHANGE};
        use winapi::um::winuser::SendMessageW;
        if self.handle.blank() { panic!("{}", NOT_BOUND); }
        let handle = self.handle.hwnd().expect(BAD_HANDLE);
        let parent_handle_raw = wh::get_window_parent(handle);
        let parent_handle = ControlHandle::Hwnd(parent_handle_raw);
        let handler0 = bind_raw_event_handler_inner(&parent_handle, handle as usize, move |_hwnd, msg, _w, l| { unsafe {
            match msg {
                WM_NOTIFY => {
                    let nmhdr: &NMHDR = mem::transmute(l);
                    if nmhdr.code == TCN_SELCHANGE {
                        let index = SendMessageW(handle, TCM_GETCURSEL, 0, 0) as i32;
                        let data: (HWND, i32) = (handle, index);
                        let data_ptr = &data as *const (HWND, i32);
                        EnumChildWindows(handle, Some(toggle_children_tabs), data_ptr as LPARAM);
                    }
                },
                _ => {}
            }
            None
        } });
        let handler1 = bind_raw_event_handler_inner(&self.handle, handle as usize, move |hwnd, msg, _w, l| { unsafe {
            match msg {
                WM_SIZE => {
                    use winapi::shared::windef::{RECT, HGDIOBJ};
                    use winapi::um::winuser::{GetDC, DrawTextW, ReleaseDC, DT_CALCRECT, DT_LEFT};
                    use winapi::um::wingdi::SelectObject;
                    let size = l as u32;
                    let width = LOWORD(size) as i32;
                    let height = HIWORD(size) as i32;
                    let (w, h) = crate::win32::high_dpi::physical_to_logical(width, height);
                    let mut data = ResizeDirectChildrenParams {
                        parent: hwnd,
                        width: w as u32,
                        height: h as u32,
                        tab_offset_y: 0
                    };
                    // Get the height of the tabs
                    let font_handle = wh::get_window_font(hwnd);
                    let mut r: RECT = mem::zeroed();
                    let dc = GetDC(hwnd);
                    let old = SelectObject(dc, font_handle as HGDIOBJ);
                    let calc: [u16;2] = [75, 121];
                    DrawTextW(dc, calc.as_ptr(), 2, &mut r, DT_CALCRECT | DT_LEFT);
                    SelectObject(dc, old);
                    ReleaseDC(hwnd, dc);
                    // Fix the width/height of the tabs
                    const BORDER_SIZE: u32 = 11;
                    let tab_height = r.bottom as u32 + BORDER_SIZE;
                    if data.width > BORDER_SIZE { data.width -= BORDER_SIZE; }
                    if data.height > tab_height { 
                        data.height -= (tab_height + BORDER_SIZE).min(data.height);
                    }
                    data.tab_offset_y = tab_height;
                    let data_ptr = &data as *const ResizeDirectChildrenParams;
                    EnumChildWindows(hwnd, Some(resize_direct_children), mem::transmute(data_ptr));
                },
                _ => {}
            }
            None
        } } );
        *self.handler0.borrow_mut() = Some(handler0.unwrap());
        *self.handler1.borrow_mut() = Some(handler1.unwrap());
    }
fn hook_tabs ( & self ) { use crate :: bind_raw_event_handler_inner ; use winapi :: shared :: minwindef :: { HIWORD , LOWORD } ; use winapi :: um :: winuser :: { NMHDR , WM_SIZE , WM_NOTIFY } ; use winapi :: um :: commctrl :: { TCM_GETCURSEL , TCN_SELCHANGE } ; use winapi :: um :: winuser :: SendMessageW ; if self . handle . blank ( ) { panic ! ( " " NOT_BOUND ) ; } let handle = self . handle . hwnd ( ) . expect ( BAD_HANDLE ) ; let parent_handle_raw = wh :: get_window_parent ( handle ) ; let parent_handle = ControlHandle :: Hwnd ( parent_handle_raw ) ; let handler0 = bind_raw_event_handler_inner ( & parent_handle , handle as usize , move | _hwnd , msg , _w , l | { unsafe { match msg { WM_NOTIFY => { let nmhdr : & NMHDR = mem :: transmute ( l ) ; if nmhdr . code == TCN_SELCHANGE { let index = SendMessageW ( handle , TCM_GETCURSEL , 0 , 0 ) as i32 ; let data : ( HWND , i32 ) = ( handle , index ) ; let data_ptr = & data as * const ( HWND , i32 ) ; EnumChildWindows ( handle , Some ( toggle_children_tabs ) , data_ptr as LPARAM ) ; } } , _ => { } } None } } ) ; let handler1 = bind_raw_event_handler_inner ( & self . handle , handle as usize , move | hwnd , msg , _w , l | { unsafe { match msg { WM_SIZE => { use winapi :: shared :: windef :: { RECT , HGDIOBJ } ; use winapi :: um :: winuser :: { GetDC , DrawTextW , ReleaseDC , DT_CALCRECT , DT_LEFT } ; use winapi :: um :: wingdi :: SelectObject ; let size = l as u32 ; let width = LOWORD ( size ) as i32 ; let height = HIWORD ( size ) as i32 ; let ( w , h ) = crate :: win32 :: high_dpi :: physical_to_logical ( width , height ) ; let mut data = ResizeDirectChildrenParams { parent : hwnd , width : w as u32 , height : h as u32 , tab_offset_y : 0 } ; // Get the height of the tabs let font_handle = wh :: get_window_font ( hwnd ) ; let mut r : RECT = mem :: zeroed ( ) ; let dc = GetDC ( hwnd ) ; let old = SelectObject ( dc , font_handle as HGDIOBJ ) ; let calc : [ u16 ; 2 ] = [ 75 , 121 ] ; DrawTextW ( dc , calc . as_ptr ( ) , 2 , & mut r , DT_CALCRECT | DT_LEFT ) ; SelectObject ( dc , old ) ; ReleaseDC ( hwnd , dc ) ; // Fix the width/height of the tabs const BORDER_SIZE : u32 = 11 ; let tab_height = r . bottom as u32 + BORDER_SIZE ; if data . width > BORDER_SIZE { data . width -= BORDER_SIZE ; } if data . height > tab_height { data . height -= ( tab_height + BORDER_SIZE ) . min ( data . height ) ; } data . tab_offset_y = tab_height ; let data_ptr = & data as * const ResizeDirectChildrenParams ; EnumChildWindows ( hwnd , Some ( resize_direct_children ) , mem :: transmute ( data_ptr ) ) ; } , _ => { } } None } } ) ; * self . handler0 . borrow_mut ( ) = Some ( handler0 . unwrap ( ) ) ; * self . handler1 . borrow_mut ( ) = Some ( handler1 . unwrap ( ) ) ; }
The tab widget lacks basic functionalities on it's own.
The tab widget lacks basic functionalities on it ' s own .
&self