Changeset 1949 for trunk/src


Ignore:
Timestamp:
Dec 2, 1999, 8:30:41 PM (26 years ago)
Author:
sandervl
Message:

Rewrote EnumThreadWindows/EnumWindows, Fixed GetParent

Location:
trunk/src/user32
Files:
3 edited

Legend:

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

    r1926 r1949  
    1 /* $Id: win32wbase.cpp,v 1.101 1999-12-01 18:43:08 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.102 1999-12-02 19:30:40 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    415415  else
    416416  {
     417        SetParent(0);
    417418        if (!cs->hwndParent || cs->hwndParent == windowDesktop->getWindowHandle()) {
    418419            owner = NULL;
     
    24472448//******************************************************************************
    24482449//******************************************************************************
     2450Win32BaseWindow *Win32BaseWindow::getParent()
     2451{
     2452  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
     2453  return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
     2454}
     2455//******************************************************************************
     2456//******************************************************************************
    24492457HWND Win32BaseWindow::GetParent()
    24502458{
    2451   if(getParent()) {
    2452         return getParent()->getWindowHandle();
    2453   }
    2454   else  return 0;
     2459 Win32BaseWindow *wndparent;
     2460
     2461    if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
     2462    {
     2463        return 0;
     2464    }
     2465    wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
     2466
     2467    return (wndparent) ? wndparent->getWindowHandle() : 0;
    24552468}
    24562469//******************************************************************************
     
    24762489   }
    24772490   else {
    2478     setParent(windowDesktop);
    2479         getParent()->AddChild(this);
     2491        setParent(windowDesktop);
     2492        windowDesktop->AddChild(this);
    24802493        OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
    24812494        return oldhwnd;
     
    25572570        dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
    25582571        hwnd = child->getWindowHandle();
     2572        if(child->getOwner()) {
     2573                continue; //shouldn't have an owner (Wine)
     2574        }
    25592575        if(lpfn(hwnd, lParam) == FALSE)
    25602576        {
     
    25802596    }
    25812597    return rc;
     2598}
     2599//******************************************************************************
     2600//Enumerate first-level children only and check thread id
     2601//******************************************************************************
     2602BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
     2603{
     2604 Win32BaseWindow *child = 0;
     2605 ULONG  tid, pid;
     2606 BOOL   rc;
     2607 HWND   hwnd;
     2608
     2609    dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
     2610
     2611    for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
     2612    {
     2613        OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
     2614       
     2615        if(dwThreadId == tid) {
     2616            dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
     2617            if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
     2618                break;
     2619            }
     2620        }
     2621    }
     2622    return TRUE;
     2623}
     2624//******************************************************************************
     2625//Enumerate first-level children only
     2626//******************************************************************************
     2627BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
     2628{
     2629 Win32BaseWindow *child = 0;
     2630 BOOL   rc;
     2631 HWND   hwnd;
     2632
     2633    dprintf(("EnumWindows %x %x", lpfn, lParam));
     2634
     2635    for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
     2636    {
     2637        hwnd = child->getWindowHandle();
     2638
     2639        dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
     2640        if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
     2641            break;
     2642        }
     2643    }
     2644    return TRUE;
    25822645}
    25832646//******************************************************************************
  • trunk/src/user32/win32wbase.h

    r1920 r1949  
    1 /* $Id: win32wbase.h,v 1.47 1999-12-01 16:58:29 achimha Exp $ */
     1/* $Id: win32wbase.h,v 1.48 1999-12-02 19:30:41 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    122122virtual  BOOL   isMDIChild();
    123123
    124 Win32BaseWindow *getParent()                    { return (Win32BaseWindow *)ChildWindow::GetParent(); };
     124Win32BaseWindow *getParent();
    125125         void   setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
    126126       WNDPROC  getWindowProc()                 { return win32wndproc; };
     
    229229
    230230           BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
     231           BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
     232           BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
    231233
    232234         HWND   getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
  • trunk/src/user32/window.cpp

    r1839 r1949  
    1 /* $Id: window.cpp,v 1.38 1999-11-25 19:22:04 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.39 1999-12-02 19:30:41 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    13241324BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
    13251325{
    1326  Win32BaseWindow *window;
    1327  BOOL   rc;
    1328  ULONG  henum;
    1329  HWND   hwndNext;
    1330  ULONG  tid;
    1331  ULONG  pid, curpid;
    1332 
    1333   dprintf(("EnumThreadWindows\n"));
    1334 
    1335   curpid = GetCurrentProcessId();
    1336 
    1337   henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
    1338   while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
    1339   {
    1340         OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
    1341         if(!(curpid == pid && dwThreadId == tid))
    1342                 continue;
    1343 
    1344         window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
    1345         if(window == NULL) {
    1346                 window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
    1347                 if(!window) {
    1348                         //OS/2 window or non-frame window, so skip it
    1349                         continue;
    1350                 }
    1351         }
    1352         if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
    1353                 break;
    1354   }
    1355   OSLibWinEndEnumWindows (henum);
    1356   return TRUE;
     1326  return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
    13571327}
    13581328//******************************************************************************
     
    13821352BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
    13831353{
    1384  Win32BaseWindow *window;
    1385  BOOL   rc;
    1386  ULONG  henum;
    1387  HWND   hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
    1388 
    1389   dprintf(("EnumThreadWindows\n"));
    1390 
    1391   do {
    1392         henum = OSLibWinBeginEnumWindows(hwndParent);
    1393         while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
    1394         {
    1395                 window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
    1396                 if(window == NULL) {
    1397                         window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
    1398                         if(!window) {
    1399                             //OS/2 window or non-frame window, so skip it
    1400                             continue;
    1401                         }
    1402                 }
    1403                 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
    1404                         goto Abort;
    1405                 }
    1406         }
    1407         if(hwndParent == OSLIB_HWND_OBJECT)
    1408                 break;
    1409         hwndParent = OSLIB_HWND_OBJECT;
    1410         OSLibWinEndEnumWindows(henum);
    1411   }
    1412   while(TRUE);
    1413 
    1414 Abort:
    1415   OSLibWinEndEnumWindows(henum);
    1416   return TRUE;
     1354  return windowDesktop->EnumWindows(lpfn, lParam);
    14171355}
    14181356//******************************************************************************
     
    14531391HWND WIN32API GetLastActivePopup( HWND hWnd)
    14541392{
    1455     dprintf(("USER32:  GetLastActivePopup"));
     1393 HWND hwnd;
     1394
    14561395    hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
    14571396
    1458     return Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
     1397    hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
     1398
     1399    dprintf(("GetLastActivePopup %x returned %x", hWnd, hwnd));
     1400    return hwnd;
    14591401}
    14601402//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.