Changeset 314 for trunk/src


Ignore:
Timestamp:
Jul 16, 1999, 1:32:10 PM (26 years ago)
Author:
sandervl
Message:

Misc window class changes/bugfixes

Location:
trunk/src/user32/new
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/makefile

    r309 r314  
    1 # $Id: makefile,v 1.2 1999-07-15 18:03:01 sandervl Exp $
     1# $Id: makefile,v 1.3 1999-07-16 11:32:08 sandervl Exp $
    22
    33#
     
    2828        pmwindow.obj win32class.obj win32wnd.obj win32dlg.obj \
    2929        msgbox.obj window.obj windowmsg.obj windowclass.obj windlgmsg.obj \
    30         windowword.obj gen_object.obj oslibwin.obj
     30        windowword.obj gen_object.obj oslibwin.obj win32wndchild.obj
    3131
    3232
     
    6767
    6868msgbox.obj:    msgbox.cpp
    69 window.obj:    window.cpp win32class.h win32wnd.h
    70 windowmsg.obj: windowmsg.cpp win32class.h win32wnd.h
    71 windlgmsg.obj: windlgmsg.cpp win32class.h win32wnd.h win32dlg.h
    72 windowclass.obj: windowclass.cpp win32class.h win32wnd.h
    73 windowword.obj:  windowword.cpp win32class.h win32wnd.h win32dlg.h
     69window.obj:    window.cpp win32class.h win32wnd.h win32wndchild.h
     70windowmsg.obj: windowmsg.cpp win32class.h win32wnd.h win32wndchild.h
     71windlgmsg.obj: windlgmsg.cpp win32class.h win32wnd.h win32dlg.h win32wndchild.h
     72windowclass.obj: windowclass.cpp win32class.h win32wnd.h win32wndchild.h
     73windowword.obj:  windowword.cpp win32class.h win32wnd.h win32dlg.h win32wndchild.h
    7474
    75 pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h
    76 win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
    77 win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
    78 win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
     75pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h
     76win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
     77win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
     78win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
     79win32wndchild.obj: win32wndchild.cpp win32wndchild.h
    7980gen_object.obj: gen_object.cpp gen_object.h
    8081oslibwin.obj:   oslibwin.cpp oslibwin.h
  • trunk/src/user32/new/oslibwin.cpp

    r309 r314  
    1 /* $Id: oslibwin.cpp,v 1.3 1999-07-15 18:03:02 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.4 1999-07-16 11:32:08 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    131131//******************************************************************************
    132132//******************************************************************************
    133 
     133HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
     134{
     135  return WinCreateMenu(hwndParent, menutemplate);
     136}
     137//******************************************************************************
     138//******************************************************************************
     139HWND OSLibWinQueryTopMostChildWindow(HWND hwndParent)
     140{
     141  return WinQueryWindow(hwndParent, QW_TOP);
     142}
     143//******************************************************************************
     144//******************************************************************************
  • trunk/src/user32/new/oslibwin.h

    r309 r314  
    1 /* $Id: oslibwin.h,v 1.2 1999-07-15 18:03:02 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.3 1999-07-16 11:32:08 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    3030BOOL  OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam);
    3131
     32HWND  OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate);
     33
     34HWND  OSLibWinQueryTopMostChildWindow(HWND hwndParent);
     35
    3236#endif //__OSLIBWIN_H__
  • trunk/src/user32/new/win32wnd.cpp

    r309 r314  
    1 /* $Id: win32wnd.cpp,v 1.3 1999-07-15 18:03:02 sandervl Exp $ */
     1/* $Id: win32wnd.cpp,v 1.4 1999-07-16 11:32:09 sandervl Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    4545//******************************************************************************
    4646Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    47                         : GenericObject(&windows, OBJTYPE_WINDOW)
     47                        : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
    4848{
    4949  Init();
     
    6868  magic            = WIN32PM_MAGIC;
    6969  OS2Hwnd          = 0;
     70  OS2HwndMenu      = 0;
    7071  Win32Hwnd        = 0;
    7172
     
    7677        DebugInt3();
    7778  }
     79  Win32Hwnd       &= 0xFFFF;
     80  Win32Hwnd       |= 0x68000000;
     81
    7882  posx = posy      = 0;
    7983  width = height   = 0;
     
    8387  win32wndproc     = 0;
    8488  hInstance        = 0;
    85   parent           = 0;
    8689  windowId         = 0xFFFFFFFF;        //default = -1
    8790  userData         = 0;
     
    110113{
    111114 char  buffer[256];
    112  DWORD tmp;
    113115 INT   sw = SW_SHOW;
    114116 POINT maxSize, maxPos, minTrack, maxTrack;
     
    220222  if ((cs->style & WS_CHILD) && cs->hwndParent)
    221223  {
    222         if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
    223         {
    224                 dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent));
    225                 return FALSE;
    226         }
    227         parent = (Win32Window *)tmp;
     224        SetParent(cs->hwndParent);
    228225  }
    229226  else
    230227  {
    231         parent = NULL;  //desktop
    232228        if (!cs->hwndParent) {
    233229                owner = NULL;
     
    235231        else
    236232        {
    237                 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
     233                owner = GetWindowFromHandle(cs->hwndParent);
     234                if(owner == NULL)
    238235                {
    239236                        dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
    240237                        return FALSE;
    241238                }
    242                 owner = (Win32Window *)tmp;
    243239        }
    244240  }
     
    251247  hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
    252248                  ? HWND_BOTTOM : HWND_TOP;
     249
     250#if 0
     251//TODO
     252    /* Call the WH_CBT hook */
     253
     254    if (HOOK_IsHooked( WH_CBT ))
     255    {
     256        CBT_CREATEWNDA cbtc;
     257        LRESULT ret;
     258
     259        cbtc.lpcs = cs;
     260        cbtc.hwndInsertAfter = hwndLinkAfter;
     261        ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
     262                      : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
     263        if (ret)
     264        {
     265            TRACE_(win)("CBT-hook returned 0\n");
     266            wndPtr->pDriver->pFinalize(wndPtr);
     267            retvalue =  0;
     268            goto end;
     269        }
     270    }
     271#endif
    253272
    254273  /* Increment class window counter */
     
    296315  }
    297316
    298   /* Set the window menu */
    299   if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
    300   {
    301         if (cs->hMenu) SetMenu(getWindowHandle(), cs->hMenu);
    302         else
    303         {
    304                 if (windowClass->getMenuNameA()) {
    305                         cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
    306                         if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu );
    307                 }
    308         }
    309   }
    310   else  windowId = (UINT)cs->hMenu;
     317  rectWindow.left   = cs->x;
     318  rectWindow.top    = cs->y;
     319  rectWindow.right  = cs->x + cs->cx;
     320  rectWindow.bottom = cs->y + cs->cy;
     321  rectClient        = rectWindow;
    311322
    312323  DWORD dwOSWinStyle, dwOSFrameStyle;
     
    314325  OSLibWinConvertStyle(cs->style, &dwOSWinStyle, &dwOSFrameStyle);
    315326
    316   OS2Hwnd = OSLibWinCreateWindow((parent) ? parent->getOS2WindowHandle() : 0,
     327  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : 0,
    317328                                 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
    318329                                 cs->x, cs->y, cs->cx, cs->cy,
     
    333344  }
    334345
    335   return TRUE;
    336 }
     346  /* Set the window menu */
     347  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
     348  {
     349        if (cs->hMenu) SetMenu(cs->hMenu);
     350        else
     351        {
     352                if (windowClass->getMenuNameA()) {
     353                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
     354                        if (cs->hMenu) SetMenu(cs->hMenu );
     355                }
     356        }
     357  }
     358  else  windowId = (UINT)cs->hMenu;
     359
     360  /* Send the WM_CREATE message
     361   * Perhaps we shouldn't allow width/height changes as well.
     362   * See p327 in "Internals".
     363   */
     364  maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
     365
     366  if(sendMessage(WM_NCCREATE, 0, (LPARAM)cs) )
     367  {
     368        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
     369        OffsetRect(&rectWindow, maxPos.x - rectWindow.left,
     370                                          maxPos.y - rectWindow.top);
     371        dprintf(("Sending WM_CREATE"));
     372        if( (sendMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
     373        {
     374            /* Send the size messages */
     375            dprintf(("Sent WM_CREATE"));
     376
     377            if (!(flags & WIN_NEED_SIZE))
     378            {
     379                /* send it anyway */
     380                if (((rectClient.right-rectClient.left) <0)
     381                    ||((rectClient.bottom-rectClient.top)<0))
     382                  dprintf(("sending bogus WM_SIZE message 0x%08lx\n",
     383                        MAKELONG(rectClient.right-rectClient.left,
     384                                 rectClient.bottom-rectClient.top)));
     385                SendMessageA(WM_SIZE, SIZE_RESTORED,
     386                                MAKELONG(rectClient.right-rectClient.left,
     387                                         rectClient.bottom-rectClient.top));
     388                SendMessageA(WM_MOVE, 0,
     389                                MAKELONG( rectClient.left,
     390                                          rectClient.top ) );
     391            }
     392
     393#if 0
     394            /* Show the window, maximizing or minimizing if needed */
     395
     396            if (dwStyle & (WS_MINIMIZE | WS_MAXIMIZE))
     397            {
     398                RECT16 newPos;
     399                UINT16 swFlag = (dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
     400                dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE);
     401                WINPOS_MinMaximize(swFlag, &newPos );
     402                swFlag = ((dwStyle & WS_CHILD) || GetActiveWindow())
     403                    ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
     404                    : SWP_NOZORDER | SWP_FRAMECHANGED;
     405                SetWindowPos(0, newPos.left, newPos.top,
     406                             newPos.right, newPos.bottom, swFlag );
     407            }
     408#endif
     409
     410            if( dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     411            {
     412                /* Notify the parent window only */
     413
     414                NotifyParent(WM_CREATE, 0, 0);
     415                if( !IsWindow(Win32Hwnd) )
     416                {
     417                    return FALSE;
     418                }
     419            }
     420
     421            if (cs->style & WS_VISIBLE) ShowWindow( sw );
     422
     423#if 0
     424            /* Call WH_SHELL hook */
     425
     426            if (!(dwStyle & WS_CHILD) && !owner)
     427                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
     428#endif
     429            return TRUE;
     430        }
     431  }
     432  return FALSE;
     433}
     434#if 0
     435/***********************************************************************
     436 *           WINPOS_MinMaximize
     437 *
     438 * Fill in lpRect and return additional flags to be used with SetWindowPos().
     439 * This function assumes that 'cmd' is different from the current window
     440 * state.
     441 */
     442UINT Win32Window::MinMaximize(UINT16 cmd, LPRECT16 lpRect )
     443{
     444    UINT swpFlags = 0;
     445    POINT pt, size;
     446    LPINTERNALPOS lpPos;
     447
     448    size.x = rectWindow.left; size.y = rectWindow.top;
     449    lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow );
     450
     451    if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd))
     452    {
     453        if( dwStyle & WS_MINIMIZE )
     454        {
     455            if( !SendMessageA(WM_QUERYOPEN, 0, 0L ) )
     456                return (SWP_NOSIZE | SWP_NOMOVE);
     457            swpFlags |= SWP_NOCOPYBITS;
     458        }
     459        switch( cmd )
     460        {
     461            case SW_MINIMIZE:
     462                 if( dwStyle & WS_MAXIMIZE)
     463                 {
     464                     flags |= WIN_RESTORE_MAX;
     465                     dwStyle &= ~WS_MAXIMIZE;
     466                 }
     467                 else
     468                     flags &= ~WIN_RESTORE_MAX;
     469                 dwStyle |= WS_MINIMIZE;
     470
     471#if 0
     472                 if( flags & WIN_NATIVE )
     473                     if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
     474                         swpFlags |= MINMAX_NOSWP;
     475#endif
     476
     477                 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
     478
     479                 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
     480                         GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     481                 swpFlags |= SWP_NOCOPYBITS;
     482                 break;
     483
     484            case SW_MAXIMIZE:
     485                CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
     486                WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
     487                CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
     488
     489                 if( dwStyle & WS_MINIMIZE )
     490                 {
     491                     if( flags & WIN_NATIVE )
     492                         if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     493                             swpFlags |= MINMAX_NOSWP;
     494
     495                     WINPOS_ShowIconTitle( wndPtr, FALSE );
     496                     dwStyle &= ~WS_MINIMIZE;
     497                 }
     498                 dwStyle |= WS_MAXIMIZE;
     499
     500                 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
     501                                    size.x, size.y );
     502                 break;
     503
     504            case SW_RESTORE:
     505                 if( dwStyle & WS_MINIMIZE )
     506                 {
     507                     if( flags & WIN_NATIVE )
     508                         if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     509                             swpFlags |= MINMAX_NOSWP;
     510
     511                     dwStyle &= ~WS_MINIMIZE;
     512                     WINPOS_ShowIconTitle( wndPtr, FALSE );
     513
     514                     if( flags & WIN_RESTORE_MAX)
     515                     {
     516                         /* Restore to maximized position */
     517                         CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
     518                         WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
     519                         CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
     520                         dwStyle |= WS_MAXIMIZE;
     521                         SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
     522                         break;
     523                     }
     524                 }
     525                 else
     526                     if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
     527                     else dwStyle &= ~WS_MAXIMIZE;
     528
     529                 /* Restore to normal position */
     530
     531                *lpRect = lpPos->rectNormal;
     532                 lpRect->right -= lpRect->left;
     533                 lpRect->bottom -= lpRect->top;
     534
     535                 break;
     536        }
     537    } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
     538    return swpFlags;
     539}
     540#endif
    337541/*******************************************************************
    338542 *           GetMinMaxInfo
     
    379583
    380584#if 0
    381     lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos );
     585    lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
    382586    if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
    383587        CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
     
    407611    if (minTrack) *minTrack = MinMax.ptMinTrackSize;
    408612    if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
     613}
     614/***********************************************************************
     615 *           WINPOS_SendNCCalcSize
     616 *
     617 * Send a WM_NCCALCSIZE message to a window.
     618 * All parameters are read-only except newClientRect.
     619 * oldWindowRect, oldClientRect and winpos must be non-NULL only
     620 * when calcValidRect is TRUE.
     621 */
     622LONG Win32Window::SendNCCalcSize(BOOL calcValidRect,
     623                            RECT *newWindowRect, RECT *oldWindowRect,
     624                            RECT *oldClientRect, WINDOWPOS *winpos,
     625                            RECT *newClientRect )
     626{
     627   NCCALCSIZE_PARAMS params;
     628   WINDOWPOS winposCopy;
     629   LONG result;
     630
     631   params.rgrc[0] = *newWindowRect;
     632   if (calcValidRect)
     633   {
     634        winposCopy = *winpos;
     635        params.rgrc[1] = *oldWindowRect;
     636        params.rgrc[2] = *oldClientRect;
     637        params.lppos = &winposCopy;
     638   }
     639   result = SendMessageA(WM_NCCALCSIZE, calcValidRect,
     640                          (LPARAM)&params );
     641   *newClientRect = params.rgrc[0];
     642   return result;
    409643}
    410644//******************************************************************************
     
    613847//******************************************************************************
    614848//******************************************************************************
    615 LRESULT Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
     849BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
    616850{
    617851 POSTMSG_PACKET *postmsg;
     
    620854  if(postmsg == NULL) {
    621855        dprintf(("Win32Window::PostMessageA: malloc returned NULL!!"));
     856        return 0;
    622857  }
    623858  postmsg->Msg    = msg;
     
    628863//******************************************************************************
    629864//******************************************************************************
    630 LRESULT Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
     865BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
    631866{
    632867 POSTMSG_PACKET *postmsg;
     
    635870  if(postmsg == NULL) {
    636871        dprintf(("Win32Window::PostMessageW: malloc returned NULL!!"));
     872        return 0;
    637873  }
    638874  postmsg->Msg    = msg;
     
    642878}
    643879//******************************************************************************
     880//TODO: do we need to inform the parent of the parent (etc) of the child window?
    644881//******************************************************************************
    645882void Win32Window::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
     
    665902        window = parentwindow;
    666903   }
     904}
     905//******************************************************************************
     906//******************************************************************************
     907BOOL Win32Window::SetMenu(ULONG hMenu)
     908{
     909 PVOID menutemplate;
     910
     911   if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR)
     912   {
     913        OS2HwndMenu = OSLibWinCreateMenu(OS2Hwnd, menutemplate);
     914        if(OS2HwndMenu == 0) {
     915                dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
     916                return FALSE;
     917        }
     918   }
     919   dprintf(("Win32Window::SetMenu unknown hMenu (%x)", hMenu));
     920   return FALSE;
     921}
     922//******************************************************************************
     923//******************************************************************************
     924BOOL Win32Window::ShowWindow(ULONG nCmdShow)
     925{
     926  return O32_ShowWindow(OS2Hwnd, nCmdShow);
     927}
     928//******************************************************************************
     929//******************************************************************************
     930BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
     931{
     932 Win32Window *window;
     933
     934  switch(hwndInsertAfter) {
     935        case HWND_BOTTOM:
     936        case HWND_TOP:
     937        case HWND_TOPMOST:
     938        case HWND_NOTOPMOST:
     939                break;
     940        default:
     941                window = GetWindowFromHandle(hwndInsertAfter);
     942                if(window) {
     943                        hwndInsertAfter = window->getOS2WindowHandle();
     944                }
     945                else {
     946                        dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter));
     947                        hwndInsertAfter = 0;
     948                }
     949                break;
     950               
     951  }
     952  return O32_SetWindowPos(OS2Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags);
     953}
     954//******************************************************************************
     955BOOL Win32Window::DestroyWindow()
     956{
     957  return TRUE;
     958}
     959//******************************************************************************
     960//TODO:
     961//******************************************************************************
     962HWND Win32Window::SetActiveWindow()
     963{
     964  return O32_SetActiveWindow(OS2Hwnd);
     965}
     966//******************************************************************************
     967//******************************************************************************
     968HWND Win32Window::GetParent()
     969{
     970  if(getParent()) {
     971        return getParent()->getWindowHandle();
     972  }
     973  else  return 0;
     974}
     975//******************************************************************************
     976//******************************************************************************
     977HWND Win32Window::SetParent(HWND hwndNewParent)
     978{
     979 HWND oldhwnd;
     980 Win32Window *newparent;
     981
     982   if(getParent()) {
     983        oldhwnd = getParent()->getWindowHandle();
     984   }
     985   else oldhwnd = 0;
     986
     987   if(hwndNewParent == 0) {//desktop window = parent
     988        setParent(NULL);
     989        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     990        return oldhwnd;
     991   }
     992   newparent = GetWindowFromHandle(hwndNewParent);
     993   if(newparent)
     994   {
     995        setParent(newparent);
     996        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     997        return oldhwnd;
     998   }
     999   SetLastError(ERROR_INVALID_PARAMETER);
     1000   return 0;
     1001}
     1002//******************************************************************************
     1003//******************************************************************************
     1004BOOL Win32Window::IsChild(HWND hwndParent)
     1005{
     1006  if(getParent()) {
     1007        return getParent()->getWindowHandle() == hwndParent;
     1008  }
     1009  else  return 0;
     1010}
     1011//******************************************************************************
     1012//******************************************************************************
     1013HWND Win32Window::GetTopWindow()
     1014{
     1015 HWND topchild;
     1016
     1017  topchild = OSLibWinQueryTopMostChildWindow(OS2Hwnd);
     1018  if(topchild)
     1019  {//TODO
     1020        return topchild;
     1021  }
     1022  else  return 0;
     1023}
     1024//******************************************************************************
     1025//TODO
     1026//******************************************************************************
     1027BOOL Win32Window::UpdateWindow()
     1028
     1029  return TRUE;
     1030}
     1031//******************************************************************************
     1032//TODO
     1033//******************************************************************************
     1034BOOL Win32Window::IsIconic()
     1035{
     1036  return FALSE;
    6671037}
    6681038//******************************************************************************
     
    6901060                return oldval;
    6911061        case GWL_HWNDPARENT:
    692         {
    693          ULONG tmp;
    694 
    695                 if(getParent()) {
    696                         oldval = getParent()->getWindowHandle();
    697                 }
    698                 else    oldval = 0;
    699 
    700                 if(value == 0) {//desktop window = parent
    701                         setParent(NULL);
    702                         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    703                         return oldval;
    704                 }
    705                 if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR)
    706                 {
    707                         setParent((Win32Window *)tmp);
    708                         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    709                         return oldval;
    710                 }
    711                 SetLastError(ERROR_INVALID_PARAMETER);
    712                 return 0;
    713         }
     1062                return SetParent((HWND)value);
     1063
    7141064        case GWL_ID:
    7151065                oldval = getWindowId();
     
    7901140//******************************************************************************
    7911141//******************************************************************************
     1142Win32Window *Win32Window::GetWindowFromHandle(HWND hwnd)
     1143{
     1144 Win32Window *window;
     1145
     1146   if(HIWORD(hwnd) != 0x6800)
     1147        return NULL;
     1148
     1149   if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
     1150        return window;
     1151   }
     1152   else return NULL;
     1153}
     1154//******************************************************************************
     1155//******************************************************************************
    7921156GenericObject *Win32Window::windows  = NULL;
  • trunk/src/user32/new/win32wnd.h

    r309 r314  
    1 /* $Id: win32wnd.h,v 1.3 1999-07-15 18:03:03 sandervl Exp $ */
     1/* $Id: win32wnd.h,v 1.4 1999-07-16 11:32:09 sandervl Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    1717#include <win32class.h>
    1818#include <gen_object.h>
     19#include <win32wndchild.h>
    1920
    2021class Win32Window;
    21 
    22 #define WIN2OS2HWND(a)  (Win32Window*)(a^a)
    23 #define OS22WINHWND(a)  (a^a)
    2422
    2523#define OFFSET_WIN32WNDPTR      0
     
    4442#define WM_WIN32_POSTMESSAGEW   0x4001
    4543
    46 class Win32Window : public GenericObject
     44class Win32Window : private GenericObject, private ChildWindow
    4745{
    4846public:
     
    7775         HWND   getWindowHandle()               { return Win32Hwnd; };
    7876         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
    79    Win32Window *getParent()                     { return parent; };
    80          void   setParent(Win32Window *pwindow) { parent = pwindow; };
     77   Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
     78         void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
    8179       WNDPROC  getWindowProc()                 { return win32wndproc; };
    8280         void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
     
    8785         void   setFlags(DWORD newflags)        { flags = newflags; };
    8886
     87         BOOL   SetMenu(ULONG hMenu);
     88         BOOL   ShowWindow(ULONG nCmdShow);
     89         BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
     90         BOOL   DestroyWindow();
     91         HWND   SetActiveWindow();
     92         HWND   GetParent();
     93         HWND   SetParent(HWND hwndNewParent);
     94         BOOL   IsChild(HWND hwndParent);
     95         HWND   GetTopWindow();
     96         BOOL   UpdateWindow();
     97         BOOL   IsIconic();
     98
    8999       LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    90100       LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    91        LRESULT  PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    92        LRESULT  PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     101       BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     102       BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    93103       LRESULT  DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
    94104       LRESULT  DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
     
    98108Win32WndClass  *getClass()  { return windowClass; };
    99109
     110static Win32Window *GetWindowFromHandle(HWND hwnd);
     111
    100112protected:
    101113        void    Init();
    102114
    103 
    104115        HWND    OS2Hwnd;
     116        HWND    OS2HwndMenu;
    105117        HWND    Win32Hwnd;
    106118        BOOL    isUnicode;
     
    113125      WNDPROC   win32wndproc;           //GWL_WNDPROC
    114126        ULONG   hInstance;              //GWL_HINSTANCE
    115    Win32Window *parent;                 //GWL_HWNDPARENT
     127//Moved in ChildWindow class
     128/////   Win32Window *parent;                    //GWL_HWNDPARENT
    116129        ULONG   windowId;               //GWL_ID
    117130        ULONG   userData;               //GWL_USERDATA
     
    131144        ULONG   nrUserWindowLong;
    132145
     146        RECT    rectWindow;
     147        RECT    rectClient;
     148
    133149Win32WndClass  *windowClass;
    134150
     
    136152
    137153private:
     154#ifndef OS2_INCLUDED
    138155        BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
    139156
    140157        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
     158
     159        LONG  SendNCCalcSize(BOOL calcValidRect,
     160                             RECT *newWindowRect, RECT *oldWindowRect,
     161                             RECT *oldClientRect, WINDOWPOS *winpos,
     162                             RECT *newClientRect );
     163
     164     LRESULT  sendMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
     165     {
     166        if(isUnicode)
     167                return SendMessageW(msg, wParam, lParam);
     168        else    return SendMessageA(msg, wParam, lParam);
     169     }
     170#endif
    141171};
    142172
  • trunk/src/user32/new/window.cpp

    r304 r314  
    1 /* $Id: window.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
     1/* $Id: window.cpp,v 1.3 1999-07-16 11:32:09 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    178178//******************************************************************************
    179179//******************************************************************************
    180 BOOL WIN32API DestroyWindow(HWND arg1)
    181 {
    182 #ifdef DEBUG
    183     WriteLog("USER32:  DestroyWindow\n");
    184 #endif
    185     return O32_DestroyWindow(arg1);
    186 }
    187 //******************************************************************************
    188 //******************************************************************************
    189 HWND WIN32API SetActiveWindow( HWND arg1)
    190 {
    191 #ifdef DEBUG
    192     WriteLog("USER32:  SetActiveWindow\n");
    193 #endif
    194     return O32_SetActiveWindow(arg1);
    195 }
    196 //******************************************************************************
    197 //******************************************************************************
    198 HWND WIN32API GetParent( HWND arg1)
    199 {
    200 #ifdef DEBUG
    201 ////    WriteLog("USER32:  GetParent\n");
    202 #endif
    203     return O32_GetParent(arg1);
    204 }
    205 //******************************************************************************
    206 //******************************************************************************
    207 HWND WIN32API SetParent( HWND arg1, HWND  arg2)
    208 {
    209 #ifdef DEBUG
    210     WriteLog("USER32:  SetParent\n");
    211 #endif
    212     return O32_SetParent(arg1, arg2);
    213 }
    214 //******************************************************************************
    215 //******************************************************************************
    216 BOOL WIN32API IsChild( HWND arg1, HWND  arg2)
    217 {
    218 #ifdef DEBUG
    219     WriteLog("USER32:  IsChild\n");
    220 #endif
    221     return O32_IsChild(arg1, arg2);
    222 }
    223 //******************************************************************************
    224 //******************************************************************************
    225 HWND WIN32API GetTopWindow( HWND arg1)
    226 {
    227 #ifdef DEBUG
    228 ////    WriteLog("USER32:  GetTopWindow\n");
    229 #endif
    230     return O32_GetTopWindow(arg1);
     180BOOL WIN32API DestroyWindow(HWND hwnd)
     181{
     182  Win32Window *window;
     183
     184    window = Win32Window::GetWindowFromHandle(hwnd);
     185    if(!window) {
     186        dprintf(("SendMessageA, window %x not found", hwnd));
     187        return 0;
     188    }
     189    return window->DestroyWindow();
     190}
     191//******************************************************************************
     192//******************************************************************************
     193HWND WIN32API SetActiveWindow( HWND hwnd)
     194{
     195  Win32Window *window;
     196
     197    window = Win32Window::GetWindowFromHandle(hwnd);
     198    if(!window) {
     199        dprintf(("SendMessageA, window %x not found", hwnd));
     200        return 0;
     201    }
     202    return window->SetActiveWindow();
     203}
     204//******************************************************************************
     205//******************************************************************************
     206HWND WIN32API GetParent( HWND hwnd)
     207{
     208  Win32Window *window;
     209
     210    window = Win32Window::GetWindowFromHandle(hwnd);
     211    if(!window) {
     212        dprintf(("SendMessageA, window %x not found", hwnd));
     213        return 0;
     214    }
     215    return window->GetParent();
     216}
     217//******************************************************************************
     218//******************************************************************************
     219HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
     220{
     221  Win32Window *window;
     222
     223    window = Win32Window::GetWindowFromHandle(hwndChild);
     224    if(!window) {
     225        dprintf(("SendMessageA, window %x not found", hwndChild));
     226        return 0;
     227    }
     228    return window->SetParent(hwndNewParent);
     229}
     230//******************************************************************************
     231//******************************************************************************
     232BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
     233{
     234  Win32Window *window;
     235
     236    window = Win32Window::GetWindowFromHandle(hwnd);
     237    if(!window) {
     238        dprintf(("SendMessageA, window %x not found", hwnd));
     239        return 0;
     240    }
     241    return window->IsChild(hwndParent);
     242}
     243//******************************************************************************
     244//******************************************************************************
     245HWND WIN32API GetTopWindow( HWND hwnd)
     246{
     247  Win32Window *window;
     248
     249    window = Win32Window::GetWindowFromHandle(hwnd);
     250    if(!window) {
     251        dprintf(("SendMessageA, window %x not found", hwnd));
     252        return 0;
     253    }
     254    return window->GetTopWindow();
    231255}
    232256//******************************************************************************
     
    234258BOOL WIN32API UpdateWindow(HWND hwnd)
    235259{
    236   dprintf(("USER32:  UpdateWindow\n"));
    237 
    238   return O32_UpdateWindow(hwnd);
    239 }
    240 //******************************************************************************
    241 //******************************************************************************
    242 BOOL WIN32API IsIconic( HWND arg1)
    243 {
    244 #ifdef DEBUG
    245     WriteLog("USER32:  IsIconic\n");
    246 #endif
    247     return O32_IsIconic(arg1);
     260  Win32Window *window;
     261
     262    window = Win32Window::GetWindowFromHandle(hwnd);
     263    if(!window) {
     264        dprintf(("SendMessageA, window %x not found", hwnd));
     265        return 0;
     266    }
     267    return window->UpdateWindow();
     268}
     269//******************************************************************************
     270//******************************************************************************
     271BOOL WIN32API IsIconic( HWND hwnd)
     272{
     273  Win32Window *window;
     274
     275    window = Win32Window::GetWindowFromHandle(hwnd);
     276    if(!window) {
     277        dprintf(("SendMessageA, window %x not found", hwnd));
     278        return 0;
     279    }
     280    return window->IsIconic();
    248281}
    249282//******************************************************************************
  • trunk/src/user32/new/windowclass.cpp

    r311 r314  
    1 /* $Id: windowclass.cpp,v 1.4 1999-07-15 18:54:55 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.5 1999-07-16 11:32:09 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    1919#include <win32class.h>
    2020#include <win32wnd.h>
    21 #include <handlemanager.h>
    2221
    2322//******************************************************************************
     
    261260
    262261    dprintf(("USER32: GetClassNameA\n"));
    263     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     262    wnd = Win32Window::GetWindowFromHandle(hwnd);
     263    if(!wnd) {
    264264        dprintf(("GetClassNameA wnd == NULL"));
    265265        return(0);
     
    274274
    275275    dprintf(("USER32: GetClassNameW\n"));
    276     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     276    wnd = Win32Window::GetWindowFromHandle(hwnd);
     277    if(!wnd) {
    277278        dprintf(("GetClassNameA wnd == NULL"));
    278279        return(0);
     
    287288
    288289    dprintf(("USER32: SetClassLongA\n"));
    289     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     290    wnd = Win32Window::GetWindowFromHandle(hwnd);
     291    if(!wnd) {
    290292        dprintf(("SetClassLongA wnd == NULL"));
    291293        return(0);
     
    300302
    301303    dprintf(("USER32: SetClassLongW\n"));
    302     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     304    wnd = Win32Window::GetWindowFromHandle(hwnd);
     305    if(!wnd) {
    303306        dprintf(("SetClassLongW wnd == NULL"));
    304307        return(0);
     
    313316
    314317    dprintf(("USER32: SetClassWordA\n"));
    315     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     318    wnd = Win32Window::GetWindowFromHandle(hwnd);
     319    if(!wnd) {
    316320        dprintf(("SetClassWordA wnd == NULL"));
    317321        return(0);
     
    326330
    327331    dprintf(("USER32: GetClassWordA\n"));
    328     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     332    wnd = Win32Window::GetWindowFromHandle(hwnd);
     333    if(!wnd) {
    329334        dprintf(("GetClassWordA wnd == NULL"));
    330335        return(0);
     
    339344
    340345    dprintf(("USER32: GetClassLongA\n"));
    341     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     346    wnd = Win32Window::GetWindowFromHandle(hwnd);
     347    if(!wnd) {
    342348        dprintf(("GetClassLongA wnd == NULL"));
    343349        return(0);
     
    352358
    353359    dprintf(("USER32: GetClassLongW\n"));
    354     if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
     360    wnd = Win32Window::GetWindowFromHandle(hwnd);
     361    if(!wnd) {
    355362        dprintf(("GetClassLongW wnd == NULL"));
    356363        return(0);
  • trunk/src/user32/new/windowmsg.cpp

    r310 r314  
    1 /* $Id: windowmsg.cpp,v 1.4 1999-07-15 18:41:46 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.5 1999-07-16 11:32:10 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    1616#include <misc.h>
    1717#include <win32wnd.h>
    18 #include <handlemanager.h>
    1918#include <win.h>
    2019#include <hooks.h>
     
    4746    if (!msg->hwnd) return 0;
    4847
    49     if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
     48    window = Win32Window::GetWindowFromHandle(msg->hwnd);
     49    if(!window) {
    5050        dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
    5151        return 0;
     
    5858
    5959#if 0
    60     if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
     60    window = Win32Window::GetWindowFromHandle(msg->hwnd);
     61    if(!window) {
    6162        dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
    6263        return 0;
     
    9394    if (!msg->hwnd) return 0;
    9495
    95     if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
     96    window = Win32Window::GetWindowFromHandle(msg->hwnd);
     97    if(!window) {
    9698        dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
    9799        return 0;
     
    104106
    105107#if 0
    106     if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
     108    window = Win32Window::GetWindowFromHandle(msg->hwnd);
     109    if(!window) {
    107110        dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
    108111        return 0;
     
    136139  Win32Window *window;
    137140
    138     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
     141    window = Win32Window::GetWindowFromHandle(hwnd);
     142    if(!window) {
    139143        dprintf(("SendMessageA, window %x not found", hwnd));
    140144        return 0;
     
    149153  Win32Window *window;
    150154
    151     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
     155    window = Win32Window::GetWindowFromHandle(hwnd);
     156    if(!window) {
    152157        dprintf(("SendMessageW, window %x not found", hwnd));
    153158        return 0;
     
    165170        return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam);
    166171
    167     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
     172    window = Win32Window::GetWindowFromHandle(hwnd);
     173    if(!window) {
    168174        dprintf(("PostMessageA, window %x not found", hwnd));
    169175        return 0;
     
    181187        return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam);
    182188
    183     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
     189    window = Win32Window::GetWindowFromHandle(hwnd);
     190    if(!window) {
    184191        dprintf(("PostMessageW, window %x not found", hwnd));
    185192        return 0;
  • trunk/src/user32/new/windowword.cpp

    r300 r314  
    1 /* $Id: windowword.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: windowword.cpp,v 1.2 1999-07-16 11:32:10 sandervl Exp $ */
    22
    33/*
     
    1414
    1515#include <win32wnd.h>
    16 #include <handlemanager.h>
    1716
    1817//******************************************************************************
     
    2221 Win32Window *window;
    2322
    24     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     23    window = Win32Window::GetWindowFromHandle(hwnd);
     24    if(window)
    2525    {
    2626        return window->SetWindowLongA(nIndex, arg3);
     
    3838 Win32Window *window;
    3939
    40     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     40    window = Win32Window::GetWindowFromHandle(hwnd);
     41    if(window)
    4142    {
    4243        return window->SetWindowLongA(nIndex, arg3);
     
    5455 Win32Window *window;
    5556
    56     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     57    window = Win32Window::GetWindowFromHandle(hwnd);
     58    if(window)
    5759    {
    5860        return window->GetWindowWord(nIndex);
     
    7072 Win32Window *window;
    7173
    72     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     74    window = Win32Window::GetWindowFromHandle(hwnd);
     75    if(window)
    7376    {
    7477        return window->SetWindowWord(nIndex, arg3);
     
    8689 Win32Window *window;
    8790
    88     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     91    window = Win32Window::GetWindowFromHandle(hwnd);
     92    if(window)
    8993    {
    9094        return window->GetWindowLongA(nIndex);
     
    102106 Win32Window *window;
    103107
    104     if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
     108    window = Win32Window::GetWindowFromHandle(hwnd);
     109    if(window)
    105110    {
    106111        return window->GetWindowLongA(nIndex);
Note: See TracChangeset for help on using the changeset viewer.