Changeset 25

Show
Ignore:
Timestamp:
02/19/08 19:33:40 (7 months ago)
Author:
Chris Miller
Message:

Fixes to tabbing through controls; fixes TabControl? issues.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/win32/dfl/control.d

    r22 r25  
    969969    private void _ctrladded(ControlEventArgs cea) 
    970970    { 
     971        /+ 
    971972        if(!(_exStyle() & WS_EX_CONTROLPARENT)) 
    972973        { 
    973             //if(_style() & WS_CHILD) 
    974974            if(!(cbits & CBits.FORM)) 
    975                 _exStyle(_exStyle() | WS_EX_CONTROLPARENT); 
    976         } 
     975            { 
     976                //if((cea.control._style() & WS_TABSTOP) || (cea.control._exStyle() & WS_EX_CONTROLPARENT)) 
     977                    _exStyle(_exStyle() | WS_EX_CONTROLPARENT); 
     978            } 
     979        } 
     980        +/ 
    977981         
    978982        onControlAdded(cea); 
     
    37103714     
    37113715     
     3716    private static bool _eachild(HWND hw, bool delegate(HWND hw) callback, inout size_t xiter) 
     3717    { 
     3718        for(; hw; hw = GetWindow(hw, GW_HWNDNEXT)) 
     3719        { 
     3720            if(!xiter) 
     3721                return false; 
     3722            xiter--; 
     3723             
     3724            LONG st = GetWindowLongA(hw, GWL_STYLE); 
     3725            if(!(st & WS_VISIBLE)) 
     3726                continue; 
     3727            if(st & WS_DISABLED) 
     3728                continue; 
     3729             
     3730            if(!callback(hw)) 
     3731                return false; 
     3732             
     3733            //LONG exst = GetWindowLongA(hw, GWL_EXSTYLE); 
     3734            //if(exst & WS_EX_CONTROLPARENT) // It's no longer added. 
     3735            { 
     3736                HWND hwc = GetWindow(hw, GW_CHILD); 
     3737                if(hwc) 
     3738                { 
     3739                    if(!_eachild(hwc, callback, xiter)) 
     3740                        return false; 
     3741                } 
     3742            } 
     3743        } 
     3744        return true; 
     3745    } 
     3746     
     3747    package static void eachGoodChildHandle(HWND hwtoplevel, bool delegate(HWND hw) callback) 
     3748    { 
     3749        HWND hw = GetWindow(hwtoplevel, GW_CHILD); 
     3750        size_t xiter = 2000; 
     3751        _eachild(hw, callback, xiter); 
     3752    } 
     3753     
     3754     
     3755    package static void _dlgselnext(HWND hwdlg, HWND hwcursel, bool forward) 
     3756    { 
     3757        if(forward) 
     3758        { 
     3759            bool foundthis = false, tdone = false; 
     3760            HWND hwfirst; 
     3761            eachGoodChildHandle(hwdlg, 
     3762                (HWND hw) 
     3763                { 
     3764                    if(hw == hwcursel) 
     3765                    { 
     3766                        foundthis = true; 
     3767                    } 
     3768                    else 
     3769                    { 
     3770                        LONG st = GetWindowLongA(hw, GWL_STYLE); 
     3771                        if(st & WS_TABSTOP) 
     3772                        { 
     3773                            if(foundthis) 
     3774                            { 
     3775                                DefDlgProcA(hwdlg, WM_NEXTDLGCTL, cast(WPARAM)hw, MAKELPARAM(true, 0)); 
     3776                                tdone = true; 
     3777                                return false; // Break. 
     3778                            } 
     3779                            else 
     3780                            { 
     3781                                if(HWND.init == hwfirst) 
     3782                                    hwfirst = hw; 
     3783                            } 
     3784                        } 
     3785                    } 
     3786                    return true; // Continue. 
     3787                }); 
     3788            if(!tdone && HWND.init != hwfirst) 
     3789                DefDlgProcA(hwdlg, WM_NEXTDLGCTL, cast(WPARAM)hwfirst, MAKELPARAM(true, 0)); 
     3790        } 
     3791        else 
     3792        { 
     3793            HWND hwprev; 
     3794            eachGoodChildHandle(hwdlg, 
     3795                (HWND hw) 
     3796                { 
     3797                    if(hw == hwcursel) 
     3798                    { 
     3799                        if(HWND.init != hwprev) // Otherwise, keep looping and get last one. 
     3800                            return false; // Break. 
     3801                    } 
     3802                    LONG st = GetWindowLongA(hw, GWL_STYLE); 
     3803                    if(st & WS_TABSTOP) 
     3804                        hwprev = hw; 
     3805                    return true; // Continue. 
     3806                }); 
     3807            if(HWND.init != hwprev) 
     3808                DefDlgProcA(hwdlg, WM_NEXTDLGCTL, cast(WPARAM)hwprev, MAKELPARAM(true, 0)); 
     3809        } 
     3810    } 
     3811     
     3812     
    37123813    /// 
    37133814    final void select() 
     
    37263827            return; 
    37273828         
    3728         // To-do: check if correct implementation. 
    3729         Control ctrl
    3730         ctrl = findForm(); 
    3731         if(ctrl && ctrl !is this) 
    3732         { 
     3829        Control ctrltoplevel; 
     3830        ctrltoplevel = findForm()
     3831        if(ctrltoplevel && ctrltoplevel !is this) 
     3832        { 
     3833           /+ // Old... 
    37333834            // Even if directed, ensure THIS one is selected first. 
    37343835            if(!directed || hwnd != GetFocus()) 
    37353836            { 
    3736                 DefDlgProcA(ctrl.handle, WM_NEXTDLGCTL, cast(WPARAM)hwnd, MAKELPARAM(true, 0)); 
     3837                DefDlgProcA(ctrltoplevel.handle, WM_NEXTDLGCTL, cast(WPARAM)hwnd, MAKELPARAM(true, 0)); 
    37373838            } 
    37383839             
    37393840            if(directed) 
    37403841            { 
    3741                 DefDlgProcA(ctrl.handle, WM_NEXTDLGCTL, !forward, MAKELPARAM(false, 0)); 
     3842                DefDlgProcA(ctrltoplevel.handle, WM_NEXTDLGCTL, !forward, MAKELPARAM(false, 0)); 
     3843            } 
     3844            +/ 
     3845             
     3846            if(directed) 
     3847            { 
     3848                _dlgselnext(ctrltoplevel.handle, this.handle, forward); 
     3849            } 
     3850            else 
     3851            { 
     3852                DefDlgProcA(ctrltoplevel.handle, WM_NEXTDLGCTL, cast(WPARAM)this.handle, MAKELPARAM(true, 0)); 
    37423853            } 
    37433854        } 
  • trunk/win32/dfl/form.d

    r24 r25  
    27702770                                    if(WM_KEYDOWN == m.msg) 
    27712771                                    { 
    2772                                         /+ 
    2773                                         Message mm; 
    2774                                         mm.hWnd = form.handle; 
    2775                                         mm.msg = WM_NEXTDLGCTL; 
    2776                                         mm.lParam = MAKEWPARAM(FALSE, 0); // wParam is direction. 
    27772772                                        if(GetKeyState(VK_SHIFT) & 0x8000) 
    2778                                             mm.wParam = 1; 
     2773                                        { 
     2774                                            // Backwards... 
     2775                                            //DefDlgProcA(form.handle, WM_NEXTDLGCTL, 1, MAKELPARAM(FALSE, 0)); 
     2776                                            _dlgselnext(form.handle, m.hWnd, false); 
     2777                                        } 
    27792778                                        else 
    2780                                             mm.wParam = 0; 
    2781                                         form.wndProc(mm); 
    2782                                         +/ 
    2783                                         if(GetKeyState(VK_SHIFT) & 0x8000) 
    2784                                             DefDlgProcA(form.handle, WM_NEXTDLGCTL, 1, MAKELPARAM(FALSE, 0)); 
    2785                                         else 
    2786                                             DefDlgProcA(form.handle, WM_NEXTDLGCTL, 0, MAKELPARAM(FALSE, 0)); 
     2779                                        { 
     2780                                            // Forwards... 
     2781                                            //DefDlgProcA(form.handle, WM_NEXTDLGCTL, 0, MAKELPARAM(FALSE, 0)); 
     2782                                            _dlgselnext(form.handle, m.hWnd, true); 
     2783                                        } 
    27872784                                    } 
    27882785                                    return true; // Prevent. 
     
    28352832                            +/ 
    28362833                            +/ 
    2837                              
    2838                             size_t xiter; 
    2839                             bool _eachild(HWND hw, bool delegate(HWND hw) callback) 
    2840                             { 
    2841                                 for(; hw; hw = GetWindow(hw, GW_HWNDNEXT)) 
    2842                                 { 
    2843                                     if(!xiter) 
    2844                                         return false; 
    2845                                     xiter--; 
    2846                                      
    2847                                     LONG st = GetWindowLongA(hw, GWL_STYLE); 
    2848                                     if(!(st & WS_VISIBLE)) 
    2849                                         continue; 
    2850                                     if(st & WS_DISABLED) 
    2851                                         continue; 
    2852                                      
    2853                                     if(!callback(hw)) 
    2854                                         return false; 
    2855                                      
    2856                                     LONG exst = GetWindowLongA(hw, GWL_EXSTYLE); 
    2857                                     if(exst & WS_EX_CONTROLPARENT) 
    2858                                     { 
    2859                                         HWND hwc = GetWindow(hw, GW_CHILD); 
    2860                                         if(hwc) 
    2861                                         { 
    2862                                             if(!_eachild(hwc, callback)) 
    2863                                                 return false; 
    2864                                         } 
    2865                                     } 
    2866                                 } 
    2867                                 return true; 
    2868                             } 
    2869                              
    2870                             void eachGoodChild(bool delegate(HWND hw) callback) 
    2871                             { 
    2872                                 HWND hw = GetWindow(form.handle, GW_CHILD); 
    2873                                 xiter = 2000; 
    2874                                 _eachild(hw, callback); 
    2875                             } 
    28762834                             
    28772835                            bool pmnemonic(HWND hw) 
     
    28902848                            bool foundmhw = false; 
    28912849                            bool foundmn = false; 
    2892                             eachGoodChild( 
     2850                            eachGoodChildHandle(form.handle, 
    28932851                                (HWND hw) 
    28942852                                { 
     
    29142872                            { 
    29152873                                // Didn't find current control, so go from top-to-bottom. 
    2916                                 eachGoodChild( 
     2874                                eachGoodChildHandle(form.handle, 
    29172875                                    (HWND hw) 
    29182876                                    { 
     
    29282886                            { 
    29292887                                // Didn't find mnemonic after current control, so go from top-to-this. 
    2930                                 eachGoodChild( 
     2888                                eachGoodChildHandle(form.handle, 
    29312889                                    (HWND hw) 
    29322890                                    {