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

GetNextDlgGroupItem fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.