Changeset 6927 for trunk/src


Ignore:
Timestamp:
Oct 1, 2001, 7:28:09 PM (24 years ago)
Author:
sandervl
Message:

GetNextDlgGroupItem fix

Location:
trunk/src/user32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32wbase.cpp

    r6902 r6927  
    1 /* $Id: win32wbase.cpp,v 1.286 2001-09-30 22:24:41 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.287 2001-10-01 17:28:08 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    32793279
    32803280        break;
     3281
     3282    case GW_HWNDNEXTCHILD:
     3283        lock();
     3284        window = (Win32BaseWindow *)getNextChild();
     3285        if(window) {
     3286             hwndRelated = window->getWindowHandle();
     3287        }
     3288        else hwndRelated = 0;
     3289        unlock();
     3290        break;
     3291
     3292    case GW_HWNDFIRSTCHILD:
     3293        lock();
     3294        window = (Win32BaseWindow *)getFirstChild();
     3295        if(window) {
     3296             hwndRelated = window->getWindowHandle();
     3297        }
     3298        else hwndRelated = 0;
     3299        unlock();
     3300        break;
     3301
     3302    case GW_HWNDLASTCHILD:
     3303        lock();
     3304        window = (Win32BaseWindow *)getFirstChild();
     3305        if(window) {
     3306             while (window->getNextChild())
     3307             {
     3308                window = (Win32BaseWindow *)window->getNextChild();
     3309             }
     3310             hwndRelated = window->getWindowHandle();
     3311        }
     3312        else hwndRelated = 0;
     3313        unlock();
     3314        break;
    32813315    }
    32823316end:
     
    37483782{
    37493783    dwIDMenu = id;
    3750 }
    3751 //******************************************************************************
    3752 //******************************************************************************
    3753 HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
    3754 {
    3755  Win32BaseWindow *firstchild = NULL, *child, *nextchild, *lastchild;
    3756  HWND retvalue;
    3757 
    3758     lock();
    3759     if (hwndCtrl)
    3760     {
    3761         firstchild = child = GetWindowFromHandle(hwndCtrl);
    3762         if (!child)
    3763         {
    3764             retvalue = 0;
    3765             goto END;
    3766         }
    3767         /* Make sure hwndCtrl is a top-level child */
    3768         while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
    3769         {
    3770             child = child->getParent();
    3771             if(child == NULL) break;
    3772         }
    3773         if (!child || (child->getParent() != this))
    3774         {
    3775             retvalue = 0;
    3776             goto END;
    3777         }
    3778     }
    3779     else
    3780     {
    3781         /* No ctrl specified -> start from the beginning */
    3782         child = (Win32BaseWindow *)getFirstChild();
    3783         if (!child)
    3784         {
    3785             retvalue = 0;
    3786             goto END;
    3787         }
    3788 
    3789         if (fPrevious)
    3790         {
    3791             while (child->getNextChild())
    3792             {
    3793                 child = (Win32BaseWindow *)child->getNextChild();
    3794             }
    3795         }
    3796     }
    3797 
    3798     lastchild = child;
    3799     nextchild = (Win32BaseWindow *)child->getNextChild();
    3800     while (TRUE)
    3801     {
    3802         if (!nextchild || (nextchild->getStyle() & WS_GROUP))
    3803         {
    3804             /* Wrap-around to the beginning of the group */
    3805             Win32BaseWindow *pWndTemp;
    3806 
    3807             nextchild = (Win32BaseWindow *)getFirstChild();
    3808 
    3809             for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
    3810             {
    3811                 if (pWndTemp->getStyle() & WS_GROUP)
    3812                     nextchild = pWndTemp;
    3813 
    3814                 if (pWndTemp == child)
    3815                     break;
    3816             }
    3817 
    3818         }
    3819         if (nextchild == child)
    3820             break;
    3821 
    3822         if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
    3823         {
    3824             lastchild = nextchild;
    3825 
    3826             if (!fPrevious)
    3827                 break;
    3828         }
    3829 
    3830         nextchild = (Win32BaseWindow *)nextchild->getNextChild();
    3831     }
    3832     retvalue = lastchild->getWindowHandle();
    3833 END:
    3834     unlock();
    3835     if(firstchild) RELEASE_WNDOBJ(firstchild);
    3836     return retvalue;
    38373784}
    38383785//******************************************************************************
  • trunk/src/user32/win32wbase.h

    r6902 r6927  
    1 /* $Id: win32wbase.h,v 1.127 2001-09-30 22:24:42 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.128 2001-10-01 17:28:08 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    3636#define WIN32PM_MAGIC           0x12345678
    3737#define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
     38
     39#define GW_HWNDNEXTCHILD          (0x10000 | GW_HWNDNEXT)
     40#define GW_HWNDFIRSTCHILD         (0x10000 | GW_CHILD)
     41#define GW_HWNDLASTCHILD          (0x10000 | GW_HWNDLAST)
    3842
    3943#ifdef DEBUG
     
    335339           BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
    336340
    337          HWND   getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
    338341
    339342         BOOL   isComingToTop()                 { return fComingToTop; };
  • trunk/src/user32/windlg.cpp

    r6392 r6927  
    1 /* $Id: windlg.cpp,v 1.24 2001-07-23 19:16:41 sandervl Exp $ */
     1/* $Id: windlg.cpp,v 1.25 2001-10-01 17:28:09 sandervl Exp $ */
    22/*
    33 * Win32 dialog apis for OS/2
     
    491491  long result = 0;
    492492
    493     dprintf(("USER32:  GetDlgItemInt\n"));
     493    dprintf(("USER32: GetDlgItemInt %x %x %x %d", hwnd, id, translated, fSigned));
    494494    if (translated) *translated = FALSE;
    495495
     
    517517//******************************************************************************
    518518//******************************************************************************
    519 HWND WIN32API GetNextDlgGroupItem( HWND hwnd, HWND hwndCtrl, BOOL fPrevious)
    520 {
    521   Win32BaseWindow *window;
    522 
    523     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    524     if(!window) {
     519HWND WIN32API GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious)
     520{
     521    HWND hwnd, retvalue;
     522
     523    if(!IsWindow(hwndDlg) || (hwndCtrl && !IsWindow(hwndCtrl))) {
    525524        dprintf(("GetNextDlgGroupItem, window %x not found", hwnd));
    526525        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    527526        return 0;
    528527    }
    529     dprintf(("USER32:  GetNextDlgGroupItem\n"));
    530     return window->getNextDlgGroupItem(hwndCtrl, fPrevious);
     528    dprintf(("USER32: GetNextDlgGroupItem %x %x %d", hwndDlg, hwndCtrl, fPrevious));
     529
     530    #define WIN_GetFullHandle(a)        a
     531
     532    hwndDlg = WIN_GetFullHandle( hwndDlg );
     533    hwndCtrl = WIN_GetFullHandle( hwndCtrl );
     534
     535    if(hwndCtrl)
     536    {
     537        /* if the hwndCtrl is the child of the control in the hwndDlg,
     538         * then the hwndDlg has to be the parent of the hwndCtrl */
     539        if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
     540            hwndDlg = GetParent(hwndCtrl);
     541    }
     542
     543    if (hwndCtrl)
     544    {
     545        /* Make sure hwndCtrl is a top-level child */
     546        HWND parent = GetParent( hwndCtrl );
     547        while (parent && parent != hwndDlg) parent = GetParent(parent);
     548        if (parent != hwndDlg) return 0;
     549    }
     550    else
     551    {
     552        /* No ctrl specified -> start from the beginning */
     553        if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
     554#ifdef __WIN32OS2__
     555        if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLASTCHILD );
     556#else
     557        if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST );
     558#endif
     559    }
     560
     561    retvalue = hwndCtrl;
     562#ifdef __WIN32OS2__
     563    hwnd = GetWindow( hwndCtrl, GW_HWNDNEXTCHILD );
     564#else
     565    hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT );
     566#endif
     567    while (1)
     568    {
     569        if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP))
     570        {
     571            /* Wrap-around to the beginning of the group */
     572            HWND tmp;
     573
     574#ifdef __WIN32OS2__
     575            hwnd = GetWindow( hwndDlg, GW_HWNDFIRSTCHILD );
     576            for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXTCHILD ) )
     577#else
     578            hwnd = GetWindow( hwndDlg, GW_CHILD );
     579            for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) )
     580#endif
     581            {
     582                if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp;
     583                if (tmp == hwndCtrl) break;
     584            }
     585        }
     586        if (hwnd == hwndCtrl) break;
     587        if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
     588        {
     589            retvalue = hwnd;
     590            if (!fPrevious) break;
     591        }
     592#ifdef __WIN32OS2__
     593        hwnd = GetWindow( hwnd, GW_HWNDNEXTCHILD );
     594#else
     595        hwnd = GetWindow( hwnd, GW_HWNDNEXT );
     596#endif
     597    }
     598    return retvalue;
    531599}
    532600/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.