Changeset 693 for trunk/src


Ignore:
Timestamp:
Aug 25, 1999, 5:08:51 PM (26 years ago)
Author:
dengert
Message:

new window size/move code

Location:
trunk/src/user32/new
Files:
6 edited

Legend:

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

    r667 r693  
    1 # $Id: makefile,v 1.32 1999-08-24 19:15:54 phaller Exp $
     1# $Id: makefile,v 1.33 1999-08-25 15:08:50 dengert Exp $
    22
    33#
     
    9999windlgmsg.obj: windlgmsg.cpp win32class.h win32wnd.h win32dlg.h win32wndchild.h
    100100
    101 pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h $(PDWIN32_INCLUDE)\wprocess.h  oslibgdi.h
     101pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h $(PDWIN32_INCLUDE)\wprocess.h oslibgdi.h oslibwin.h
    102102win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
    103103win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h  $(PDWIN32_INCLUDE)\winres.h oslibres.h
  • trunk/src/user32/new/oslibwin.cpp

    r628 r693  
    1 /* $Id: oslibwin.cpp,v 1.23 1999-08-22 18:29:37 dengert Exp $ */
     1/* $Id: oslibwin.cpp,v 1.24 1999-08-25 15:08:50 dengert Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    55 *
    66 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
     7 * Copyright 1999 Daniela Engert (dani@ngrt.de)
    78 *
    89 *
     
    1819
    1920#include <misc.h>
     21#include "win32type.h"
    2022#include <winconst.h>
    2123#include "oslibwin.h"
     
    3133  if(hwndParent == OSLIB_HWND_DESKTOP)
    3234  {
    33         hwndParent = HWND_DESKTOP;
     35        hwndParent = HWND_DESKTOP;
    3436  }
    3537
     
    3941//******************************************************************************
    4042HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
    41                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
     43                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
    4244{
    4345 HWND  hwndClient;
     
    4648
    4749  if(pszName && *pszName == 0) {
    48         pszName = NULL;
     50        pszName = NULL;
    4951  }
    5052  if(hwndParent == OSLIB_HWND_DESKTOP) {
    51         hwndParent = HWND_DESKTOP;
     53        hwndParent = HWND_DESKTOP;
    5254  }
    5355  if(Owner == OSLIB_HWND_DESKTOP) {
    54         Owner = HWND_DESKTOP;
     56        Owner = HWND_DESKTOP;
    5557  }
    5658
    5759  if(dwFrameStyle) {
    58         ULONG dwClientStyle;
    59 
    60         dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
    61         if(pszName)
    62                 dwFrameStyle |= FCF_TITLEBAR;
    63 
    64         dwFrameStyle |= FCF_TASKLIST;
    65         *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
    66                                        &dwFrameStyle, WIN32_STDCLASS,
    67                                        "", dwClientStyle, 0, 0, &hwndClient);
    68         if(*hwndFrame) {
    69                 if(pszName) {
    70                         WinSetWindowText(*hwndFrame, pszName);
    71                 }
    72                 return hwndClient;
    73         }
    74         dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
    75         return 0;
     60        ULONG dwClientStyle;
     61
     62        dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
     63        if(pszName)
     64                dwFrameStyle |= FCF_TITLEBAR;
     65
     66        dwFrameStyle |= FCF_TASKLIST;
     67        *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
     68                                       &dwFrameStyle, WIN32_STDCLASS,
     69                                       "", dwClientStyle, 0, 0, &hwndClient);
     70        if(*hwndFrame) {
     71                if(pszName) {
     72                        WinSetWindowText(*hwndFrame, pszName);
     73                }
     74                return hwndClient;
     75        }
     76        dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
     77        return 0;
    7678  }
    7779  hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
    78                                Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
    79                                NULL);
     80                               Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
     81                               NULL);
    8082  *hwndFrame = hwndClient;
    8183  return hwndClient;
     
    8587BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
    8688{
    87   *OSWinStyle   = 0;
     89  *OSWinStyle   = 0;
    8890  *OSFrameStyle = 0;
    8991
    9092  /* Window styles */
    9193  if(dwStyle & WS_MINIMIZE_W)
    92         *OSWinStyle |= WS_MINIMIZED;
     94        *OSWinStyle |= WS_MINIMIZED;
    9395//Done explicitely in CreateWindowExA
    9496#if 0
    9597  if(dwStyle & WS_VISIBLE_W)
    96         *OSWinStyle |= WS_VISIBLE;
     98        *OSWinStyle |= WS_VISIBLE;
    9799#endif
    98100  if(dwStyle & WS_DISABLED_W)
    99         *OSWinStyle |= WS_DISABLED;
     101        *OSWinStyle |= WS_DISABLED;
    100102  if(dwStyle & WS_CLIPSIBLINGS_W)
    101         *OSWinStyle |= WS_CLIPSIBLINGS;
     103        *OSWinStyle |= WS_CLIPSIBLINGS;
    102104  if(dwStyle & WS_CLIPCHILDREN_W)
    103         *OSWinStyle |= WS_CLIPCHILDREN;
     105        *OSWinStyle |= WS_CLIPCHILDREN;
    104106  if(dwStyle & WS_MAXIMIZE_W)
    105         *OSWinStyle |= WS_MAXIMIZED;
     107        *OSWinStyle |= WS_MAXIMIZED;
    106108  if(dwStyle & WS_GROUP_W)
    107         *OSWinStyle |= WS_GROUP;
     109        *OSWinStyle |= WS_GROUP;
    108110  if(dwStyle & WS_TABSTOP_W)
    109         *OSWinStyle |= WS_TABSTOP;
     111        *OSWinStyle |= WS_TABSTOP;
    110112
    111113  if(dwStyle & WS_CAPTION_W)
    112         *OSFrameStyle |= FCF_TITLEBAR;
     114        *OSFrameStyle |= FCF_TITLEBAR;
    113115  if(dwStyle & WS_DLGFRAME_W)
    114         *OSFrameStyle |= FCF_DLGBORDER;
     116        *OSFrameStyle |= FCF_DLGBORDER;
    115117  else
    116118  if(dwStyle & WS_BORDER_W)
    117         *OSFrameStyle |= FCF_BORDER;
     119        *OSFrameStyle |= FCF_BORDER;
    118120
    119121  if(dwStyle & WS_VSCROLL_W)
    120         *OSFrameStyle |= FCF_VERTSCROLL;
     122        *OSFrameStyle |= FCF_VERTSCROLL;
    121123  if(dwStyle & WS_HSCROLL_W)
    122         *OSFrameStyle |= FCF_HORZSCROLL;
     124        *OSFrameStyle |= FCF_HORZSCROLL;
    123125  if(dwStyle & WS_SYSMENU_W)
    124         *OSFrameStyle |= FCF_SYSMENU;
     126        *OSFrameStyle |= FCF_SYSMENU;
    125127  if(dwStyle & WS_THICKFRAME_W)
    126         *OSFrameStyle |= FCF_SIZEBORDER;        //??
     128        *OSFrameStyle |= FCF_SIZEBORDER;        //??
    127129  if(dwStyle & WS_MINIMIZEBOX_W)
    128         *OSFrameStyle |= FCF_MINBUTTON;
     130        *OSFrameStyle |= FCF_MINBUTTON;
    129131  if(dwStyle & WS_MAXIMIZEBOX_W)
    130         *OSFrameStyle |= FCF_MAXBUTTON;
     132        *OSFrameStyle |= FCF_MAXBUTTON;
    131133
    132134  if(dwExStyle & WS_EX_DLGMODALFRAME_W)
    133         *OSFrameStyle |= FCF_DLGBORDER;
     135        *OSFrameStyle |= FCF_DLGBORDER;
    134136
    135137  return TRUE;
     
    226228//******************************************************************************
    227229BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
    228                           LONG cy, ULONG fl)
     230                          LONG cy, ULONG fl)
    229231{
    230232 HWND hwndParent = hwndInsertBehind;
     
    232234
    233235    if(fl & SWP_MOVE) {
    234         switch(hwndParent)
    235         {
    236             case HWNDOS_TOP:
    237             case HWNDOS_BOTTOM:
    238                 hwndParent = HWND_DESKTOP;
    239                 break;
    240         }
    241         y = MapOS2ToWin32Y(hwndParent, cy, y);
     236        switch(hwndParent)
     237        {
     238            case HWNDOS_TOP:
     239            case HWNDOS_BOTTOM:
     240                hwndParent = HWND_DESKTOP;
     241                break;
     242        }
     243        y = MapOS2ToWin32Y(hwndParent, cy, y);
    242244    }
    243245    rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
     
    247249//******************************************************************************
    248250//******************************************************************************
     251BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
     252{
     253    return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
     254}
     255//******************************************************************************
     256//******************************************************************************
    249257BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
    250258{
     
    252260
    253261  if(fl & SWP_SHOW) {
    254         rc = WinShowWindow(hwnd, TRUE);
     262        rc = WinShowWindow(hwnd, TRUE);
    255263  }
    256264  if(rc == 0)
    257         dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
     265        dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
    258266  rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
    259267  if(rc == 0)
    260         dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
     268        dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
    261269  return rc;
    262270}
     
    271279BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
    272280{
    273  BOOL     rc;
     281 BOOL     rc;
    274282 RECTLOS2 rectl;
    275283
    276284  rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
    277285  if(rc) {
    278         if(RelativeTo == RELATIVE_TO_SCREEN) {
    279                 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
    280         }
    281         else    MapOS2ToWin32Rectl(&rectl, pRect);
    282   }
    283   else  memset(pRect, 0, sizeof(RECT));
     286        if(RelativeTo == RELATIVE_TO_SCREEN) {
     287                MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
     288        }
     289        else    MapOS2ToWin32Rectl(&rectl, pRect);
     290  }
     291  else  memset(pRect, 0, sizeof(RECT));
    284292  return rc;
    285293}
     
    293301  rc = WinQueryWindowPos(hwnd, &swp);
    294302  if(rc == FALSE) {
    295         dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
    296         return FALSE;
     303        dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
     304        return FALSE;
    297305  }
    298306
    299307  if(swp.fl & SWP_MINIMIZE)
    300         return TRUE;
    301   else  return FALSE;
     308        return TRUE;
     309  else  return FALSE;
    302310}
    303311//******************************************************************************
     
    389397//******************************************************************************
    390398//******************************************************************************
    391 
     399BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
     400{
     401  return WinQueryWindowPos(hwnd, pswp);
     402}
     403//******************************************************************************
     404//******************************************************************************
     405void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, ULONG parentHeight)
     406{
     407   HWND hWindow            = pswp->hwnd;
     408   HWND hWndInsertAfter    = pswp->hwndInsertBehind;
     409   long x                  = pswp->x;
     410   long y                  = pswp->y;
     411   long cx                 = pswp->cx;
     412   long cy                 = pswp->cy;
     413   UINT fuFlags            = (UINT)pswp->fl;
     414
     415   HWND  hWinAfter;
     416   ULONG flags = 0;
     417
     418   //***************************************************
     419   // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
     420   //***************************************************
     421   HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
     422
     423   if ( hWndInsertAfter == HWND_TOP )
     424      hWinAfter = HWND_TOP_W;
     425   else if ( hWndInsertAfter == HWND_BOTTOM )
     426      hWinAfter = HWND_BOTTOM_W;
     427   else
     428      hWinAfter = (HWND) hWndInsertAfter;
     429
     430   //***********************************
     431   // convert PM flags to Windows flags
     432   //***********************************
     433   if (!(fuFlags & SWP_SIZE))       flags |= SWP_NOSIZE_W;
     434   if (!(fuFlags & SWP_MOVE))       flags |= SWP_NOMOVE_W;
     435   if (!(fuFlags & SWP_ZORDER))     flags |= SWP_NOZORDER_W;
     436   if (  fuFlags & SWP_NOREDRAW)    flags |= SWP_NOREDRAW_W;
     437   if (!(fuFlags & SWP_ACTIVATE))   flags |= SWP_NOACTIVATE_W;
     438   if (  fuFlags & SWP_SHOW)        flags |= SWP_SHOWWINDOW_W;
     439   if (  fuFlags & SWP_HIDE)        flags |= SWP_HIDEWINDOW_W;
     440
     441   //**************************************************************************
     442   // When moving or sizing we'll have to do some calculations for Y inversion.
     443   //
     444   // If moving - invert Y coord.
     445   //
     446   // If sizing - if the height is changing, have to move the window to
     447   //             maintain correct windows position.  If we just size then the
     448   //             TR corner will extend.  The Windows behaviour should be to
     449   //             extend the BR corner.
     450   //
     451   // If this is a child window then we'll have to move within the client
     452   // area of the parent.
     453   //
     454   // If this is an overlapped or popup window we'll have to move around
     455   // within the desktop.
     456   //**************************************************************************
     457   if ( fuFlags & (SWP_MOVE | SWP_SIZE) )
     458   {
     459      if (fuFlags & SWP_SIZE)
     460      {
     461         // If height is changing we MUST move to maintain top-left alignment
     462         if (cy != pswpOld->cy)
     463         {
     464            flags &= ~SWP_NOMOVE_W;
     465         }
     466      }
     467      else
     468      {
     469         cx = pswpOld->cx;
     470         cy = pswpOld->cy;
     471      }
     472
     473      //**********************************************************
     474      // We'll need both a y and cy for the Y inversion code.
     475      // If either wasn't passed in, calculate the current value.
     476      //**********************************************************
     477      if ((fuFlags & SWP_MOVE) == 0)
     478      {
     479         x = pswpOld->x;
     480         y = pswpOld->y;
     481      }
     482
     483      //********************************************************
     484      // Y inversion here... old Y is top left corner of window
     485      // relative to top left of parent.
     486      //********************************************************
     487      y = parentHeight - y - cy;
     488
     489      LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
     490
     491      // Set the SWP_NOMOVE_W flag if the window has not moved in windows
     492      // coordinates.
     493      if ( ( pswpOld->x == x ) && ( oldY == y ) )
     494         flags |= SWP_NOMOVE_W;
     495
     496      // Set the SWP_NOSIZE_W flag if the window is not really being sized.
     497      if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
     498         flags |= SWP_NOSIZE_W;
     499   }
     500
     501   // Fill in the WINDOWPOS structure with the now calculated PM values.
     502   pwpos->flags            = (UINT)flags;
     503   pwpos->cy               = (int)cy;
     504   pwpos->cx               = (int)cx;
     505   pwpos->x                = (int)x;
     506   pwpos->y                = (int)y;
     507   pwpos->hwndInsertAfter  = hWinAfter;
     508   pwpos->hwnd             = hWindow;
     509}
     510//******************************************************************************
     511//******************************************************************************
     512void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, ULONG parentHeight)
     513{
     514   HWND hWnd              = pwpos->hwnd;
     515   HWND hWndInsertAfter   = pwpos->hwndInsertAfter;
     516   long x                 = pwpos->x;
     517   long y                 = pwpos->y;
     518   long cx                = pwpos->cx;
     519   long cy                = pwpos->cy;
     520   UINT fuFlags           = pwpos->flags;
     521
     522   HWND  hWinAfter;
     523   ULONG flags = 0;
     524
     525   //***************************************************
     526   // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
     527   //***************************************************
     528   HWND  hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
     529
     530   if ( hWndInsertAfter == HWND_TOPMOST_W )
     531//      hWinAfter = HWND_TOPMOST;
     532      hWinAfter = HWND_TOP;
     533   else if ( hWndInsertAfter == HWND_NOTOPMOST_W )
     534//      hWinAfter = HWND_NOTOPMOST;
     535      hWinAfter = HWND_TOP;
     536   else if ( hWndInsertAfter == HWND_TOP_W )
     537      hWinAfter = HWND_TOP;
     538   else if ( hWndInsertAfter == HWND_BOTTOM_W )
     539      hWinAfter = HWND_BOTTOM;
     540   else
     541      hWinAfter = (HWND) hWndInsertAfter;
     542
     543   //***********************************
     544   // convert Windows flags to PM flags
     545   //***********************************
     546   if ( ! ( fuFlags & SWP_NOSIZE_W     ) ) flags |= SWP_SIZE;
     547   if ( ! ( fuFlags & SWP_NOMOVE_W     ) ) flags |= SWP_MOVE;
     548   if ( ! ( fuFlags & SWP_NOZORDER_W   ) ) flags |= SWP_ZORDER;
     549   if (     fuFlags & SWP_NOREDRAW_W   )   flags |= SWP_NOREDRAW;
     550   if ( ! ( fuFlags & SWP_NOACTIVATE_W ) ) flags |= SWP_ACTIVATE;
     551   if (     fuFlags & SWP_SHOWWINDOW_W )   flags |= SWP_SHOW;
     552   if (     fuFlags & SWP_HIDEWINDOW_W )   flags |= SWP_HIDE;
     553   /* no PM equivalent for SWP_FRAMECHANGED_W, SWP_NOCOPYBITS_W and SWP_NOOWNERZORDER_W */
     554
     555   //**************************************************************************
     556   // When moving or sizing we'll have to do some calculations for Y inversion.
     557   //
     558   // If moving - invert Y coord.
     559   //
     560   // If sizing - if the height is changing, have to move the window to
     561   //             maintain correct windows position.  If we just size then the
     562   //             TR corner will extend.  The Windows behaviour should be to
     563   //             extend the BR corner.
     564   //
     565   // If this is a child window then we'll have to move within the client
     566   // area of the parent.
     567   //
     568   // If this is an overlapped or popup window we'll have to move around
     569   // within the desktop.
     570   //**************************************************************************
     571   if ( flags & (SWP_MOVE | SWP_SIZE) )
     572   {
     573      //**********************************************************
     574      // We'll need both a y and cy for the Y inversion code.
     575      // If either wasn't passed in, calculate the current value.
     576      //**********************************************************
     577      if ((flags & SWP_MOVE) == 0)
     578      {
     579         x = pswpOld->x;
     580         y = pswpOld->y;
     581
     582         // If the window is at (x,0) with a height of zero then this calculation
     583         // won't quite work.  Instead of calculating the Windows y coord, we set
     584         // it at (x,0).
     585         if (!(y == 0 && pswpOld->cy == 0))
     586         {
     587            // convert Y coordinate back to Windows's for later conversion with new size
     588            y = parentHeight - y - pswpOld->cy;
     589         }
     590      }
     591
     592      if (flags & SWP_SIZE)
     593      {
     594         // If height is changing we MUST move to maintain top-left alignment
     595         if (cy != pswpOld->cy)
     596            flags |= SWP_MOVE;
     597      }
     598      else
     599      {
     600         cx = pswpOld->cx;
     601         cy = pswpOld->cy;
     602      }
     603
     604      //********************************************************
     605      // Y inversion here... old Y is top left corner of window
     606      // relative to top left of parent.
     607      //********************************************************
     608      y = parentHeight - y - cy;
     609
     610      // Clear the SWP_MOVE flag if the window is not really being moved.
     611      if ( ( pswpOld->x == x ) && ( pswpOld->y == y ) )
     612         flags &= ~SWP_MOVE;
     613
     614      // Clear the SWP_SIZE flag if the window is not really being sized.
     615      if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
     616         flags &= ~SWP_SIZE;
     617   }
     618
     619   // Fill in the WINDOWPOS structure with the now calculated PM values.
     620   pswp->fl               = flags;
     621   pswp->cy               = cy;
     622   pswp->cx               = cx;
     623   pswp->x                = x;
     624   pswp->y                = y;
     625   pswp->hwndInsertBehind = hWinAfter;
     626   pswp->hwnd             = hWindow;
     627   pswp->ulReserved1      = 0;
     628   pswp->ulReserved2      = 0;
     629}
     630//******************************************************************************
     631//******************************************************************************
     632
  • trunk/src/user32/new/oslibwin.h

    r601 r693  
    1 /* $Id: oslibwin.h,v 1.20 1999-08-20 20:09:51 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.21 1999-08-25 15:08:50 dengert Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    55 *
    66 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
     7 * Copyright 1999      Daniela Engert (dani@ngrt.de)
    78 *
    89 *
     
    1314#define __OSLIBWIN_H__
    1415#include <oslibgdi.h>
     16
     17#ifndef WIN_INCLUDED
     18typedef struct _SWP    /* swp */
     19{
     20   ULONG   fl;
     21   LONG    cy;
     22   LONG    cx;
     23   LONG    y;
     24   LONG    x;
     25   HWND    hwndInsertBehind;
     26   HWND    hwnd;
     27   ULONG   ulReserved1;
     28   ULONG   ulReserved2;
     29} SWP, *PSWP;
     30#endif
    1531
    1632#define OSLIB_HWND_DESKTOP      0
     
    3955BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus);
    4056ULONG OSLibGetWindowHeight(HWND hwnd); //for point transformation
     57
     58extern ULONG ScreenHeight;
     59inline ULONG OSLibQueryScreenHeight(void) { return (ScreenHeight); }
    4160
    4261//reserved deleted
     
    168187
    169188BOOL  OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl);
     189BOOL  OSLibWinSetMultWindowPos(struct _SWP *pswp, ULONG num);
    170190BOOL  OSLibWinShowWindow(HWND hwnd, ULONG fl);
    171191
     
    213233BOOL  OSLibWinSetIcon(HWND hwnd, HANDLE hIcon);
    214234
     235BOOL  OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp);
     236void  OSLibMapSWPtoWINDOWPOS(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, ULONG parentHeight);
     237void  OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, ULONG parentHeight);
     238
    215239#endif //__OSLIBWIN_H__
  • trunk/src/user32/new/pmwindow.cpp

    r650 r693  
    1 /* $Id: pmwindow.cpp,v 1.20 1999-08-23 15:34:46 dengert Exp $ */
     1/* $Id: pmwindow.cpp,v 1.21 1999-08-25 15:08:50 dengert Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    1313#define INCL_GPI
    1414
    15 #include <os2.h>                        /* PM header file               */
     15#include <os2.h>                        /* PM header file               */
    1616#include <os2wrap.h>
    1717#include <stdlib.h>
    1818#include "win32type.h"
     19#include <winconst.h>
    1920#include <wprocess.h>
    2021#include <misc.h>
     
    2728#include "oslibmsg.h"
    2829
    29 HMQ  hmq = 0;                             /* Message queue handle         */
     30HMQ  hmq = 0;                             /* Message queue handle         */
    3031HAB  hab = 0;
    3132
    3233RECTL desktopRectl = {0};
     34ULONG ScreenWidth  = 0;
     35ULONG ScreenHeight = 0;
    3336
    3437MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    4548  if(!hab || !hmq)
    4649  {
    47         UINT error;
    48         //CB: only fail on real error
    49         error = WinGetLastError(hab) & 0xFFFF; //error code
    50         if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
    51         {
    52             dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
    53             dprintf((" Error = %x",error));
    54             return(FALSE);
    55         }
     50        UINT error;
     51        //CB: only fail on real error
     52        error = WinGetLastError(hab) & 0xFFFF; //error code
     53        if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
     54        {
     55            dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
     56            dprintf((" Error = %x",error));
     57            return(FALSE);
     58        }
    5659    else
    57         {
    58         if(!hab) {
    59                 hab = WinQueryAnchorBlock(HWND_DESKTOP);
    60             dprintf(("WinQueryAnchorBlock returned %x", hab));
    61         }
    62         if(!hmq) {
    63             hmq = HMQ_CURRENT;
    64         }
    65         }
     60        {
     61        if(!hab) {
     62                hab = WinQueryAnchorBlock(HWND_DESKTOP);
     63            dprintf(("WinQueryAnchorBlock returned %x", hab));
     64        }
     65        if(!hmq) {
     66            hmq = HMQ_CURRENT;
     67        }
     68        }
    6669  }
    6770  SetThreadHAB(hab);
     
    6972  SetThreadMessageQueue(hmq);
    7073
    71   if(!WinRegisterClass(                 /* Register window class        */
    72      hab,                               /* Anchor block handle          */
    73      (PSZ)WIN32_STDCLASS,               /* Window class name            */
    74      (PFNWP)Win32WindowProc,            /* Address of window procedure  */
     74  if(!WinRegisterClass(                 /* Register window class        */
     75     hab,                               /* Anchor block handle          */
     76     (PSZ)WIN32_STDCLASS,               /* Window class name            */
     77     (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    7578     CS_SIZEREDRAW | CS_HITTEST,
    7679     8)) {
    77         dprintf(("WinRegisterClass Win32Window failed"));
    78         return(FALSE);
     80        dprintf(("WinRegisterClass Win32Window failed"));
     81        return(FALSE);
    7982   }
    8083
    8184   WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
    82    dprintf(("InitPM: Desktop (%d,%d)", desktopRectl.xRight, desktopRectl.yTop));
     85   ScreenWidth  = desktopRectl.xRight;
     86   ScreenHeight = desktopRectl.yTop;
     87
     88   dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
    8389   return OSLibInitMsgQueue();
    8490} /* End of main */
     
    8995{
    9096 POSTMSG_PACKET *postmsg;
    91  OSLIBPOINT      point, ClientPoint;
    92  Win32Window    *win32wnd;
    93  APIRET         rc;
     97 OSLIBPOINT      point, ClientPoint;
     98 Win32Window    *win32wnd;
     99 APIRET         rc;
    94100
    95101  //Restore our FS selector
     
    99105
    100106  if(msg != WM_CREATE && win32wnd == NULL) {
    101         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    102         goto RunDefWndProc;
     107        dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
     108        goto RunDefWndProc;
    103109  }
    104110  switch( msg )
     
    106112    //internal messages
    107113    case WM_WIN32_POSTMESSAGEA:
    108         postmsg = (POSTMSG_PACKET *)mp1;
    109         if(postmsg == NULL) {
    110             dprintf(("WM_WIN32_POSTMESSAGEA, postmsg NULL!!"));
    111             break;
    112         }
    113         win32wnd->SendMessageA(postmsg->Msg, postmsg->wParam, postmsg->lParam);
    114         free(postmsg);
    115         break;
     114        postmsg = (POSTMSG_PACKET *)mp1;
     115        if(postmsg == NULL) {
     116            dprintf(("WM_WIN32_POSTMESSAGEA, postmsg NULL!!"));
     117            break;
     118        }
     119        win32wnd->SendMessageA(postmsg->Msg, postmsg->wParam, postmsg->lParam);
     120        free(postmsg);
     121        break;
    116122
    117123    case WM_WIN32_POSTMESSAGEW:
    118         postmsg = (POSTMSG_PACKET *)mp1;
    119         if(postmsg == NULL) {
    120             dprintf(("WM_WIN32_POSTMESSAGEW, postmsg NULL!!"));
    121             break;
    122         }
    123         win32wnd->SendMessageW(postmsg->Msg, postmsg->wParam, postmsg->lParam);
    124         free(postmsg);
    125         break;
     124        postmsg = (POSTMSG_PACKET *)mp1;
     125        if(postmsg == NULL) {
     126            dprintf(("WM_WIN32_POSTMESSAGEW, postmsg NULL!!"));
     127            break;
     128        }
     129        win32wnd->SendMessageW(postmsg->Msg, postmsg->wParam, postmsg->lParam);
     130        free(postmsg);
     131        break;
    126132
    127133    //OS/2 msgs
    128134    case WM_CREATE:
    129         //Processing is done in after WinCreateWindow returns
    130         dprintf(("OS2: WM_CREATE %x", hwnd));
    131         RestoreOS2TIB();
    132         return (MRESULT)FALSE;
     135        //Processing is done in after WinCreateWindow returns
     136        dprintf(("OS2: WM_CREATE %x", hwnd));
     137        RestoreOS2TIB();
     138        return (MRESULT)FALSE;
    133139
    134140    case WM_QUIT:
    135         dprintf(("OS2: WM_QUIT %x", hwnd));
    136         if(win32wnd->MsgQuit()) {
    137                 goto RunDefWndProc;
    138         }
    139         break;
     141        dprintf(("OS2: WM_QUIT %x", hwnd));
     142        if(win32wnd->MsgQuit()) {
     143                goto RunDefWndProc;
     144        }
     145        break;
    140146
    141147    case WM_CLOSE:
    142         dprintf(("OS2: WM_CLOSE %x", hwnd));
    143         if(win32wnd->MsgClose()) {
    144                 goto RunDefWndProc;
    145         }
    146         break;
     148        dprintf(("OS2: WM_CLOSE %x", hwnd));
     149        if(win32wnd->MsgClose()) {
     150                goto RunDefWndProc;
     151        }
     152        break;
    147153
    148154    case WM_DESTROY:
    149         dprintf(("OS2: WM_DESTROY %x", hwnd));
    150         if(win32wnd->MsgDestroy()) {
    151                 goto RunDefWndProc;
    152         }
    153         break;
     155        dprintf(("OS2: WM_DESTROY %x", hwnd));
     156        if(win32wnd->MsgDestroy()) {
     157                goto RunDefWndProc;
     158        }
     159        break;
    154160
    155161    case WM_ENABLE:
    156         dprintf(("OS2: WM_ENABLE %x", hwnd));
    157         if(win32wnd->MsgEnable((ULONG)mp1)) {
    158                 goto RunDefWndProc;
    159         }
    160         break;
     162        dprintf(("OS2: WM_ENABLE %x", hwnd));
     163        if(win32wnd->MsgEnable((ULONG)mp1)) {
     164                goto RunDefWndProc;
     165        }
     166        break;
    161167
    162168    case WM_SHOW:
    163         dprintf(("OS2: WM_SHOW %x", hwnd));
    164         if(win32wnd->MsgShow((ULONG)mp1)) {
    165                 goto RunDefWndProc;
    166         }
    167         break;
     169        dprintf(("OS2: WM_SHOW %x", hwnd));
     170        if(win32wnd->MsgShow((ULONG)mp1)) {
     171                goto RunDefWndProc;
     172        }
     173        break;
    168174
    169175    case WM_ADJUSTWINDOWPOS:
    170176    {
    171       ULONG    x, y;
    172177      PSWP     pswp = (PSWP)mp1;
    173 
    174         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x", hwnd));
    175 
    176         if(pswp->fl & SWP_MOVE) {
    177             if(win32wnd->isChild()) {
    178                 x = pswp->x;
    179                 y = pswp->cy - y - 1;
    180             }
    181             else {
    182                 OSLIBPOINT point;
    183 
    184                 point.x = pswp->x;
    185                 point.y = pswp->y;
    186 
    187                 MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    188                 x = point.x;
    189                 y = point.y;
    190             }
    191             if(win32wnd->MsgMove(x, y)) {
    192                 goto RunDefWndProc;
    193             }
    194             break;
    195         }
    196         goto RunDefWndProc;
     178      SWP      swpOld;
     179      WINDOWPOS wp;
     180      ULONG    parentHeight = 0;
     181
     182        dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     183
     184        WinQueryWindowPos(hwnd, &swpOld);
     185
     186        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     187            parentHeight = (win32wnd->isChild()) ?
     188                OSLibGetWindowHeight(win32wnd->getParent()->getOS2WindowHandle())
     189              : OSLibQueryScreenHeight();
     190        }
     191        OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, parentHeight);
     192        wp.hwnd = win32wnd->getWindowHandle();
     193        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     194        {
     195           Win32Window *wndAfter = Win32Window::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     196           wp.hwndInsertAfter = wndAfter->getWindowHandle();
     197        }
     198        win32wnd->MsgPosChanging((LPARAM)&wp);
     199        break;
    197200    }
    198201
    199202    case WM_WINDOWPOSCHANGED:
    200203    {
    201      PSWP pswp = (PSWP)mp1;
    202 
    203         dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    204         goto RunDefWndProc;
     204      PSWP      pswp = (PSWP)mp1;
     205      WINDOWPOS wp;
     206      ULONG     parentHeight = 0;
     207
     208        dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     209        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     210            parentHeight = (win32wnd->isChild()) ?
     211                OSLibGetWindowHeight(win32wnd->getParent()->getOS2WindowHandle())
     212              : OSLibQueryScreenHeight();
     213        }
     214        OSLibMapSWPtoWINDOWPOS(pswp, &wp, pswp+1, parentHeight);
     215        wp.hwnd = win32wnd->getWindowHandle();
     216        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     217        {
     218           Win32Window *wndAfter = Win32Window::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     219           wp.hwndInsertAfter = wndAfter->getWindowHandle();
     220        }
     221        win32wnd->MsgPosChanged((LPARAM)&wp);
     222        break;
    205223    }
    206224
    207225    case WM_ERASEBACKGROUND:
    208226    {
    209         return (MRESULT) FALSE;
     227        return (MRESULT) FALSE;
    210228    }
    211229    case WM_SIZE:
     
    213231     SWP swp;
    214232
    215         rc = WinQueryWindowPos(hwnd, &swp);
    216         if(rc == FALSE) {
    217                 dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
    218                 break;
    219         }
    220         dprintf(("OS2: WM_SIZE %x %x (%d,%d) (%d,%d) (%d,%d)", hwnd, swp.fl, swp.x, swp.y, swp.cx, swp.cy, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)));
    221         if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
    222                                 (swp.fl & SWP_MINIMIZE) != 0,
    223                                 (swp.fl & SWP_MAXIMIZE) != 0))
    224         {
    225                 goto RunDefWndProc;
    226         }
    227         break;
     233        rc = WinQueryWindowPos(hwnd, &swp);
     234        if(rc == FALSE) {
     235                dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
     236                break;
     237        }
     238        dprintf(("OS2: WM_SIZE %x %x (%d,%d) (%d,%d) (%d,%d)", hwnd, swp.fl, swp.x, swp.y, swp.cx, swp.cy, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)));
     239#if 0
     240        if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
     241                                (swp.fl & SWP_MINIMIZE) != 0,
     242                                (swp.fl & SWP_MAXIMIZE) != 0))
     243        {
     244                goto RunDefWndProc;
     245        }
     246#endif
     247        break;
    228248    }
    229249
     
    232252      HWND hwndActivate = (HWND)mp1;
    233253
    234         dprintf(("OS2: WM_ACTIVATE %x", hwnd));
    235         if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    236                 //another (non-win32) application's window
    237                 //set to NULL (allowed according to win32 SDK) to avoid problems
    238                 hwndActivate = NULL;
    239         }
    240         if(win32wnd->MsgActivate(1, hwndActivate)) {
    241                 goto RunDefWndProc;
    242         }
    243         break;
     254        dprintf(("OS2: WM_ACTIVATE %x", hwnd));
     255        if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     256                //another (non-win32) application's window
     257                //set to NULL (allowed according to win32 SDK) to avoid problems
     258                hwndActivate = NULL;
     259        }
     260        if(win32wnd->MsgActivate(1, hwndActivate)) {
     261                goto RunDefWndProc;
     262        }
     263        break;
    244264    }
    245265    case WM_FOCUSCHANGE:
    246         dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
    247         goto RunDefWndProc;
     266        dprintf(("OS2: WM_FOCUSCHANGE %x", hwnd));
     267        goto RunDefWndProc;
    248268
    249269    case WM_SETFOCUS:
     
    251271      HWND hwndFocus = (HWND)mp1;
    252272
    253         dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
    254         if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    255                 //another (non-win32) application's window
    256                 //set to NULL (allowed according to win32 SDK) to avoid problems
    257                 hwndFocus = NULL;
    258         }
    259         if((ULONG)mp2 == TRUE) {
    260                 rc = win32wnd->MsgSetFocus(hwndFocus);
    261         }
    262         else    rc = win32wnd->MsgKillFocus(hwndFocus);
    263         if(rc) {
    264                 goto RunDefWndProc;
    265         }
    266         break;
     273        dprintf(("OS2: WM_SETFOCUS %x %d", hwnd, mp2));
     274        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     275                //another (non-win32) application's window
     276                //set to NULL (allowed according to win32 SDK) to avoid problems
     277                hwndFocus = NULL;
     278        }
     279        if((ULONG)mp2 == TRUE) {
     280                rc = win32wnd->MsgSetFocus(hwndFocus);
     281        }
     282        else    rc = win32wnd->MsgKillFocus(hwndFocus);
     283        if(rc) {
     284                goto RunDefWndProc;
     285        }
     286        break;
    267287    }
    268288    //**************************************************************************
     
    270290    //**************************************************************************
    271291    case WM_BUTTON1DOWN:
    272         dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
    273         point.x = (*(POINTS *)&mp1).x;
    274         point.y = (*(POINTS *)&mp1).y;
    275         ClientPoint.x = point.x;
    276         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    277         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    278         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    279                 goto RunDefWndProc;
    280         }
    281         break;
     292        dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
     293        point.x = (*(POINTS *)&mp1).x;
     294        point.y = (*(POINTS *)&mp1).y;
     295        ClientPoint.x = point.x;
     296        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     297        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     298        if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     299                goto RunDefWndProc;
     300        }
     301        break;
    282302
    283303    case WM_BUTTON1UP:
    284         dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
    285         point.x = (*(POINTS *)&mp1).x;
    286         point.y = (*(POINTS *)&mp1).y;
    287         ClientPoint.x = point.x;
    288         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    289         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    290         if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    291                 goto RunDefWndProc;
    292         }
    293         break;
     304        dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
     305        point.x = (*(POINTS *)&mp1).x;
     306        point.y = (*(POINTS *)&mp1).y;
     307        ClientPoint.x = point.x;
     308        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     309        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     310        if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     311                goto RunDefWndProc;
     312        }
     313        break;
    294314    case WM_BUTTON1DBLCLK:
    295         point.x = (*(POINTS *)&mp1).x;
    296         point.y = (*(POINTS *)&mp1).y;
    297         ClientPoint.x = point.x;
    298         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    299         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    300         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    301                 goto RunDefWndProc;
    302         }
    303         break;
     315        point.x = (*(POINTS *)&mp1).x;
     316        point.y = (*(POINTS *)&mp1).y;
     317        ClientPoint.x = point.x;
     318        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     319        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     320        if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     321                goto RunDefWndProc;
     322        }
     323        break;
    304324    case WM_BUTTON2DOWN:
    305         point.x = (*(POINTS *)&mp1).x;
    306         point.y = (*(POINTS *)&mp1).y;
    307         ClientPoint.x = point.x;
    308         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    309         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    310         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    311                 goto RunDefWndProc;
    312         }
    313         break;
     325        point.x = (*(POINTS *)&mp1).x;
     326        point.y = (*(POINTS *)&mp1).y;
     327        ClientPoint.x = point.x;
     328        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     329        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     330        if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     331                goto RunDefWndProc;
     332        }
     333        break;
    314334    case WM_BUTTON2UP:
    315         point.x = (*(POINTS *)&mp1).x;
    316         point.y = (*(POINTS *)&mp1).y;
    317         ClientPoint.x = point.x;
    318         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    319         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    320         if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    321                 goto RunDefWndProc;
    322         }
    323         break;
     335        point.x = (*(POINTS *)&mp1).x;
     336        point.y = (*(POINTS *)&mp1).y;
     337        ClientPoint.x = point.x;
     338        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     339        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     340        if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     341                goto RunDefWndProc;
     342        }
     343        break;
    324344    case WM_BUTTON2DBLCLK:
    325         point.x = (*(POINTS *)&mp1).x;
    326         point.y = (*(POINTS *)&mp1).y;
    327         ClientPoint.x = point.x;
    328         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    329         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    330         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    331                 goto RunDefWndProc;
    332         }
    333         break;
     345        point.x = (*(POINTS *)&mp1).x;
     346        point.y = (*(POINTS *)&mp1).y;
     347        ClientPoint.x = point.x;
     348        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     349        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     350        if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     351                goto RunDefWndProc;
     352        }
     353        break;
    334354    case WM_BUTTON3DOWN:
    335         point.x = (*(POINTS *)&mp1).x;
    336         point.y = (*(POINTS *)&mp1).y;
    337         ClientPoint.x = point.x;
    338         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    339         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    340         if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    341                 goto RunDefWndProc;
    342         }
    343         break;
     355        point.x = (*(POINTS *)&mp1).x;
     356        point.y = (*(POINTS *)&mp1).y;
     357        ClientPoint.x = point.x;
     358        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     359        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     360        if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     361                goto RunDefWndProc;
     362        }
     363        break;
    344364    case WM_BUTTON3UP:
    345         point.x = (*(POINTS *)&mp1).x;
    346         point.y = (*(POINTS *)&mp1).y;
    347         ClientPoint.x = point.x;
    348         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    349         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    350         if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    351                 goto RunDefWndProc;
    352         }
    353         break;
     365        point.x = (*(POINTS *)&mp1).x;
     366        point.y = (*(POINTS *)&mp1).y;
     367        ClientPoint.x = point.x;
     368        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     369        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     370        if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     371                goto RunDefWndProc;
     372        }
     373        break;
    354374    case WM_BUTTON3DBLCLK:
    355         point.x = (*(POINTS *)&mp1).x;
    356         point.y = (*(POINTS *)&mp1).y;
    357         ClientPoint.x = point.x;
    358         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    359         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    360         if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    361                 goto RunDefWndProc;
    362         }
    363         break;
     375        point.x = (*(POINTS *)&mp1).x;
     376        point.y = (*(POINTS *)&mp1).y;
     377        ClientPoint.x = point.x;
     378        ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
     379        MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
     380        if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     381                goto RunDefWndProc;
     382        }
     383        break;
    364384
    365385    case WM_BUTTON2MOTIONSTART:
     
    372392    case WM_BUTTON3MOTIONEND:
    373393    case WM_BUTTON3CLICK:
    374         goto RunDefWndProc;
     394        goto RunDefWndProc;
    375395
    376396    case WM_MOUSEMOVE:
    377397    {
    378         ULONG keystate = 0;
    379         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
    380             keystate |= WMMOVE_LBUTTON;
    381         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
    382             keystate |= WMMOVE_MBUTTON;
    383         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
    384             keystate |= WMMOVE_RBUTTON;
    385         if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
    386             keystate |= WMMOVE_SHIFT;
    387         if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
    388             keystate |= WMMOVE_CTRL;
    389 
    390         //OS/2 Window coordinates -> Win32 Window coordinates
    391         //TODO: What do windows apps that handle this messages return?
    392         if(!win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)))) {
    393                 goto RunDefWndProc;
    394         }
    395         break;
     398        ULONG keystate = 0;
     399        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
     400            keystate |= WMMOVE_LBUTTON;
     401        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
     402            keystate |= WMMOVE_MBUTTON;
     403        if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3))
     404            keystate |= WMMOVE_RBUTTON;
     405        if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT))
     406            keystate |= WMMOVE_SHIFT;
     407        if(WinGetKeyState(HWND_DESKTOP, VK_CTRL))
     408            keystate |= WMMOVE_CTRL;
     409
     410        //OS/2 Window coordinates -> Win32 Window coordinates
     411        //TODO: What do windows apps that handle this messages return?
     412        if(!win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)))) {
     413                goto RunDefWndProc;
     414        }
     415        break;
    396416    }
    397417
     
    405425
    406426    case WM_COMMAND:
    407         if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    408             win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
    409         }
    410         if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
    411             win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
    412         }
    413         //todo controls + accelerators
    414         break;
     427        if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
     428            win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
     429        }
     430        if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
     431            win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
     432        }
     433        //todo controls + accelerators
     434        break;
    415435
    416436    case WM_SYSCOMMAND:
     
    419439      ULONG win32sc;
    420440
    421         if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
    422             POINTL pointl;
    423             WinQueryPointerPos(HWND_DESKTOP, &pointl);
    424             x = pointl.x;
    425             y = desktopRectl.yTop - y;
    426         }
    427         switch(SHORT1FROMMP(mp1)) {
    428         case SC_MOVE:
    429             win32sc = WIN32SC_MOVE;
    430             break;
    431         case SC_CLOSE:
    432             win32sc = WIN32SC_CLOSE;
    433             break;
    434         case SC_MAXIMIZE:
    435             win32sc = WIN32SC_MAXIMIZE;
    436             break;
    437         case SC_MINIMIZE:
    438             win32sc = WIN32SC_MINIMIZE;
    439             break;
    440         case SC_NEXTFRAME:
    441         case SC_NEXTWINDOW:
    442             win32sc = WIN32SC_NEXTWINDOW;
    443             break;
    444         case SC_RESTORE:
    445             win32sc = WIN32SC_RESTORE;
    446             break;
    447         case SC_TASKMANAGER:
    448             win32sc = WIN32SC_TASKLIST;
    449             break;
    450         default:
    451             goto RunDefWndProc;
    452         }
    453         dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
    454         if(win32wnd->MsgSysCommand(win32sc, x, y)) {
    455             goto RunDefWndProc;
    456         }
    457         break;
     441        if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
     442            POINTL pointl;
     443            WinQueryPointerPos(HWND_DESKTOP, &pointl);
     444            x = pointl.x;
     445            y = ScreenHeight - y;
     446        }
     447        switch(SHORT1FROMMP(mp1)) {
     448        case SC_MOVE:
     449            win32sc = WIN32SC_MOVE;
     450            break;
     451        case SC_CLOSE:
     452            win32sc = WIN32SC_CLOSE;
     453            break;
     454        case SC_MAXIMIZE:
     455            win32sc = WIN32SC_MAXIMIZE;
     456            break;
     457        case SC_MINIMIZE:
     458            win32sc = WIN32SC_MINIMIZE;
     459            break;
     460        case SC_NEXTFRAME:
     461        case SC_NEXTWINDOW:
     462            win32sc = WIN32SC_NEXTWINDOW;
     463            break;
     464        case SC_RESTORE:
     465            win32sc = WIN32SC_RESTORE;
     466            break;
     467        case SC_TASKMANAGER:
     468            win32sc = WIN32SC_TASKLIST;
     469            break;
     470        default:
     471            goto RunDefWndProc;
     472        }
     473        dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
     474        if(win32wnd->MsgSysCommand(win32sc, x, y)) {
     475            goto RunDefWndProc;
     476        }
     477        break;
    458478    }
    459479    case WM_CHAR:
     
    462482     ULONG fl = SHORT1FROMMP(mp1);
    463483
    464         if(!(fl & KC_CHAR)) {
    465             dprintf(("WM_CHAR: no valid character code"));
    466             goto RunDefWndProc;
    467         }
    468         if(fl & KC_VIRTUALKEY) {
    469             vkey = SHORT2FROMMP(mp2);
    470         }
    471         if(fl & KC_KEYUP) {
    472             keyflags |= KEY_UP;
    473         }
    474         if(fl & KC_ALT) {
    475             keyflags |= KEY_ALTDOWN;
    476         }
    477         if(fl & KC_PREVDOWN) {
    478             keyflags |= KEY_PREVDOWN;
    479         }
    480         if(fl & KC_DEADKEY) {
    481             keyflags |= KEY_DEADKEY;
    482         }
    483         if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), vkey, keyflags)) {
    484             goto RunDefWndProc;
    485         }
    486         break;
     484        if(!(fl & KC_CHAR)) {
     485            dprintf(("WM_CHAR: no valid character code"));
     486            goto RunDefWndProc;
     487        }
     488        if(fl & KC_VIRTUALKEY) {
     489            vkey = SHORT2FROMMP(mp2);
     490        }
     491        if(fl & KC_KEYUP) {
     492            keyflags |= KEY_UP;
     493        }
     494        if(fl & KC_ALT) {
     495            keyflags |= KEY_ALTDOWN;
     496        }
     497        if(fl & KC_PREVDOWN) {
     498            keyflags |= KEY_PREVDOWN;
     499        }
     500        if(fl & KC_DEADKEY) {
     501            keyflags |= KEY_DEADKEY;
     502        }
     503        if(win32wnd->MsgChar(SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), vkey, keyflags)) {
     504            goto RunDefWndProc;
     505        }
     506        break;
    487507    }
    488508    case WM_INITMENU:
     
    492512
    493513    case WM_TIMER:
    494         goto RunDefWndProc;
     514        goto RunDefWndProc;
    495515
    496516    case WM_SETWINDOWPARAMS:
     
    498518      WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
    499519
    500         dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
    501         if(wndParams->fsStatus & WPM_TEXT) {
    502             if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
    503                     goto RunDefWndProc;
    504             }
    505         }
    506         goto RunDefWndProc;
     520        dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
     521        if(wndParams->fsStatus & WPM_TEXT) {
     522            if(win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText)) {
     523                    goto RunDefWndProc;
     524            }
     525        }
     526        goto RunDefWndProc;
    507527    }
    508528
     
    513533     PSZ   wintext;
    514534
    515         if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT)) {
    516             if(wndpars->fsStatus & WPM_CCHTEXT)
    517                 wndpars->cchText = win32wnd->MsgGetTextLength();
    518             if(wndpars->fsStatus & WPM_TEXT)
    519                 wndpars->pszText = win32wnd->MsgGetText();
    520             return (MRESULT)TRUE;
    521         }
    522         goto RunDefWndProc;
     535        if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT)) {
     536            if(wndpars->fsStatus & WPM_CCHTEXT)
     537                wndpars->cchText = win32wnd->MsgGetTextLength();
     538            if(wndpars->fsStatus & WPM_TEXT)
     539                wndpars->pszText = win32wnd->MsgGetText();
     540            return (MRESULT)TRUE;
     541        }
     542        goto RunDefWndProc;
    523543    }
    524544
    525545    case WM_PAINT:
    526         dprintf(("OS2: WM_PAINT %x", hwnd));
    527         if(win32wnd->MsgPaint(0, 0)) {
    528                 goto RunDefWndProc;
    529         }
    530         break;
     546        dprintf(("OS2: WM_PAINT %x", hwnd));
     547        if(win32wnd->MsgPaint(0, 0)) {
     548                goto RunDefWndProc;
     549        }
     550        break;
    531551
    532552    case WM_HITTEST:
    533         if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
    534                 goto RunDefWndProc;
    535         }
    536         break;
     553        if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
     554                goto RunDefWndProc;
     555        }
     556        break;
    537557
    538558    case WM_SYSCOLORCHANGE:
     
    558578    case WM_SEMANTICEVENT:
    559579    default:
    560 //        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    561         RestoreOS2TIB();
    562         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     580//        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     581        RestoreOS2TIB();
     582        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    563583  }
    564584  RestoreOS2TIB();
  • trunk/src/user32/new/win32wnd.cpp

    r650 r693  
    1 /* $Id: win32wnd.cpp,v 1.29 1999-08-23 15:34:47 dengert Exp $ */
     1/* $Id: win32wnd.cpp,v 1.30 1999-08-25 15:08:50 dengert Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    5757//******************************************************************************
    5858Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    59                         : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
     59                        : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
    6060{
    6161  Init();
     
    6767void Win32Window::Init()
    6868{
    69   isUnicode        = FALSE;
    70   fCreated         = FALSE;
    71   fFirstShow       = TRUE;
     69  isUnicode        = FALSE;
     70  fCreated         = FALSE;
     71  fFirstShow       = TRUE;
    7272
    7373  memset(windowNameA, 0, MAX_WINDOW_NAMELENGTH);
     
    7878  nrUserWindowLong = 0;
    7979
    80   magic            = WIN32PM_MAGIC;
    81   OS2Hwnd          = 0;
    82   OS2HwndFrame     = 0;
    83   OS2HwndMenu      = 0;
    84   Win32Hwnd        = 0;
     80  magic            = WIN32PM_MAGIC;
     81  OS2Hwnd          = 0;
     82  OS2HwndFrame     = 0;
     83  OS2HwndMenu      = 0;
     84  Win32Hwnd        = 0;
    8585
    8686  if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
    8787  {
    88         dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
    89         DebugInt3();
    90   }
    91   Win32Hwnd       &= 0xFFFF;
    92   Win32Hwnd       |= 0x68000000;
    93 
    94   posx = posy      = 0;
     88        dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
     89        DebugInt3();
     90  }
     91  Win32Hwnd       &= 0xFFFF;
     92  Win32Hwnd       |= 0x68000000;
     93
     94  posx = posy      = 0;
    9595  width = height   = 0;
    9696
    97   dwExStyle        = 0;
    98   dwStyle          = 0;
    99   win32wndproc     = 0;
    100   hInstance        = 0;
    101   windowId         = 0xFFFFFFFF;        //default = -1
    102   userData         = 0;
     97  dwExStyle        = 0;
     98  dwStyle          = 0;
     99  win32wndproc     = 0;
     100  hInstance        = 0;
     101  windowId         = 0xFFFFFFFF;        //default = -1
     102  userData         = 0;
    103103
    104104  hwndLinkAfter    = HWND_BOTTOM;
    105   flags            = 0;
    106   isIcon           = FALSE;
     105  flags            = 0;
     106  isIcon           = FALSE;
    107107  lastHitTestVal   = 0;
    108   owner            = NULL;
    109   windowClass      = 0;
     108  owner            = NULL;
     109  windowClass      = 0;
    110110
    111111  acceltableResource = NULL;
    112   menuResource       = NULL;
    113   iconResource       = NULL;
     112  menuResource       = NULL;
     113  iconResource       = NULL;
    114114}
    115115//******************************************************************************
     
    122122
    123123  if(Win32Hwnd)
    124         HMHandleFree(Win32Hwnd & 0xFFFF);
     124        HMHandleFree(Win32Hwnd & 0xFFFF);
    125125  if(userWindowLong)
    126         free(userWindowLong);
     126        free(userWindowLong);
    127127}
    128128//******************************************************************************
     
    145145    if (cs->hwndParent)
    146146    {
    147             Win32Window *window = GetWindowFromHandle(cs->hwndParent);
    148             if(!window) {
    149                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    150                     SetLastError(ERROR_INVALID_PARAMETER);
    151                     return FALSE;
    152             }
    153             /* Make sure parent is valid */
    154             if (!window->IsWindow() )
    155             {
    156                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    157                     SetLastError(ERROR_INVALID_PARAMETER);
    158                     return FALSE;
    159             }
     147            Win32Window *window = GetWindowFromHandle(cs->hwndParent);
     148            if(!window) {
     149                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     150                    SetLastError(ERROR_INVALID_PARAMETER);
     151                    return FALSE;
     152            }
     153            /* Make sure parent is valid */
     154            if (!window->IsWindow() )
     155            {
     156                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     157                    SetLastError(ERROR_INVALID_PARAMETER);
     158                    return FALSE;
     159            }
    160160    }
    161161    else
    162162    if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
    163             dprintf(("No parent for child window\n" ));
    164             SetLastError(ERROR_INVALID_PARAMETER);
    165             return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
     163            dprintf(("No parent for child window\n" ));
     164            SetLastError(ERROR_INVALID_PARAMETER);
     165            return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
    166166    }
    167167
     
    170170  if (!windowClass)
    171171  {
    172         GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    173         dprintf(("Bad class '%s'\n", buffer ));
    174         return 0;
     172        GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     173        dprintf(("Bad class '%s'\n", buffer ));
     174        return 0;
    175175  }
    176176
     
    180180   */
    181181  if (!HIWORD(cs->lpszClass) ) {
    182         if (isUnicode) {
    183                 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
    184         }
    185         else {
    186                 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    187         }
    188         cs->lpszClass = buffer;
     182        if (isUnicode) {
     183                GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
     184        }
     185        else {
     186                GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     187        }
     188        cs->lpszClass = buffer;
    189189  }
    190190
     
    192192  if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
    193193  {
    194 //        PDB *pdb = PROCESS_Current();
     194//        PDB *pdb = PROCESS_Current();
    195195
    196196       /* Never believe Microsoft's documentation... CreateWindowEx doc says
    197         * that if an overlapped window is created with WS_VISIBLE style bit
    198         * set and the x parameter is set to CW_USEDEFAULT, the system ignores
    199         * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
    200         * reveals that
    201         *
    202         * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
    203         * 2) it does not ignore the y parameter as the docs claim; instead, it
    204         *    uses it as second parameter to ShowWindow() unless y is either
    205         *    CW_USEDEFAULT or CW_USEDEFAULT16.
    206         *
    207         * The fact that we didn't do 2) caused bogus windows pop up when wine
    208         * was running apps that were using this obscure feature. Example -
    209         * calc.exe that comes with Win98 (only Win98, it's different from
    210         * the one that comes with Win95 and NT)
    211         */
    212         if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
    213 
    214         /* We have saved cs->y, now we can trash it */
     197        * that if an overlapped window is created with WS_VISIBLE style bit
     198        * set and the x parameter is set to CW_USEDEFAULT, the system ignores
     199        * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
     200        * reveals that
     201        *
     202        * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
     203        * 2) it does not ignore the y parameter as the docs claim; instead, it
     204        *    uses it as second parameter to ShowWindow() unless y is either
     205        *    CW_USEDEFAULT or CW_USEDEFAULT16.
     206        *
     207        * The fact that we didn't do 2) caused bogus windows pop up when wine
     208        * was running apps that were using this obscure feature. Example -
     209        * calc.exe that comes with Win98 (only Win98, it's different from
     210        * the one that comes with Win95 and NT)
     211        */
     212        if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
     213
     214        /* We have saved cs->y, now we can trash it */
    215215#if 0
    216         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    217             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
    218         {
    219             cs->x = pdb->env_db->startup_info->dwX;
    220             cs->y = pdb->env_db->startup_info->dwY;
    221         }
     216        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     217            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
     218        {
     219            cs->x = pdb->env_db->startup_info->dwX;
     220            cs->y = pdb->env_db->startup_info->dwY;
     221        }
    222222#endif
    223             cs->x = 0;
    224             cs->y = 0;
    225 //        }
     223            cs->x = 0;
     224            cs->y = 0;
     225//        }
    226226  }
    227227  if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
    228228  {
    229229#if 0
    230         PDB *pdb = PROCESS_Current();
    231         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    232             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
    233         {
    234             cs->cx = pdb->env_db->startup_info->dwXSize;
    235             cs->cy = pdb->env_db->startup_info->dwYSize;
    236         }
    237         else
    238         {
     230        PDB *pdb = PROCESS_Current();
     231        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     232            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
     233        {
     234            cs->cx = pdb->env_db->startup_info->dwXSize;
     235            cs->cy = pdb->env_db->startup_info->dwYSize;
     236        }
     237        else
     238        {
    239239#endif
    240             cs->cx = 600; /* FIXME */
    241             cs->cy = 400;
    242 //        }
     240            cs->cx = 600; /* FIXME */
     241            cs->cy = 400;
     242//        }
    243243  }
    244244
     
    249249  nrUserWindowLong = windowClass->getExtraWndWords();
    250250  if(nrUserWindowLong) {
    251         userWindowLong = (ULONG *)malloc(nrUserWindowLong);
    252         memset(userWindowLong, 0, nrUserWindowLong);
     251        userWindowLong = (ULONG *)malloc(nrUserWindowLong);
     252        memset(userWindowLong, 0, nrUserWindowLong);
    253253  }
    254254
    255255  if ((cs->style & WS_CHILD) && cs->hwndParent)
    256256  {
    257         SetParent(cs->hwndParent);
     257        SetParent(cs->hwndParent);
    258258  }
    259259  else
    260260  {
    261         if (!cs->hwndParent) {
    262             owner = NULL;
    263         }
    264         else
    265         {
    266             owner = GetWindowFromHandle(cs->hwndParent);
    267             if(owner == NULL)
    268             {
    269                 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
    270                 return FALSE;
    271             }
    272         }
     261        if (!cs->hwndParent) {
     262            owner = NULL;
     263        }
     264        else
     265        {
     266            owner = GetWindowFromHandle(cs->hwndParent);
     267            if(owner == NULL)
     268            {
     269                dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
     270                return FALSE;
     271            }
     272        }
    273273  }
    274274
     
    279279
    280280  hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
    281                   ? HWND_BOTTOM : HWND_TOP;
     281                  ? HWND_BOTTOM : HWND_TOP;
    282282
    283283#if 0
     
    288288    {
    289289    CBT_CREATEWNDA cbtc;
    290         LRESULT ret;
     290        LRESULT ret;
    291291
    292292    cbtc.lpcs = cs;
    293293    cbtc.hwndInsertAfter = hwndLinkAfter;
    294         ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
    295                       : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
    296         if (ret)
     294        ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
     295                      : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
     296        if (ret)
    297297    {
    298         TRACE_(win)("CBT-hook returned 0\n");
    299         wndPtr->pDriver->pFinalize(wndPtr);
    300             retvalue =  0;
    301             goto end;
     298        TRACE_(win)("CBT-hook returned 0\n");
     299        wndPtr->pDriver->pFinalize(wndPtr);
     300            retvalue =  0;
     301            goto end;
    302302    }
    303303    }
     
    310310  if (!(cs->style & WS_CHILD))
    311311  {
    312         dwStyle |= WS_CLIPSIBLINGS;
    313         if (!(cs->style & WS_POPUP))
    314         {
    315             dwStyle |= WS_CAPTION;
    316             flags |= WIN_NEED_SIZE;
    317         }
     312        dwStyle |= WS_CLIPSIBLINGS;
     313        if (!(cs->style & WS_POPUP))
     314        {
     315            dwStyle |= WS_CAPTION;
     316            flags |= WIN_NEED_SIZE;
     317        }
    318318  }
    319319  if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
     
    330330  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
    331331  {
    332         GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
    333         if (maxSize.x < cs->cx) cs->cx = maxSize.x;
    334         if (maxSize.y < cs->cy) cs->cy = maxSize.y;
    335         if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
    336         if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
     332        GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
     333        if (maxSize.x < cs->cx) cs->cx = maxSize.x;
     334        if (maxSize.y < cs->cy) cs->cy = maxSize.y;
     335        if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
     336        if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
    337337  }
    338338
    339339  if(cs->style & WS_CHILD)
    340340  {
    341         if(cs->cx < 0) cs->cx = 0;
    342         if(cs->cy < 0) cs->cy = 0;
     341        if(cs->cx < 0) cs->cx = 0;
     342        if(cs->cy < 0) cs->cy = 0;
    343343  }
    344344  else
    345345  {
    346         if (cs->cx <= 0) cs->cx = 1;
    347         if (cs->cy <= 0) cs->cy = 1;
     346        if (cs->cx <= 0) cs->cx = 1;
     347        if (cs->cy <= 0) cs->cy = 1;
    348348  }
    349349
     
    352352  rectWindow.right  = cs->x + cs->cx;
    353353  rectWindow.bottom = cs->y + cs->cy;
    354   rectClient        = rectWindow;
     354  rectClient        = rectWindow;
    355355
    356356  DWORD dwOSWinStyle, dwOSFrameStyle;
     
    361361#if 1
    362362  if(cs->style & WS_CHILD) {
    363         dwOSFrameStyle = 0;
     363        dwOSFrameStyle = 0;
    364364  }
    365365#endif
    366366
    367367  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    368                                 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
    369                                 (owner) ? owner->getOS2FrameWindowHandle() : OSLIB_HWND_DESKTOP,
    370                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
    371                                 &OS2HwndFrame);
     368                                dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
     369                                (owner) ? owner->getOS2FrameWindowHandle() : OSLIB_HWND_DESKTOP,
     370                                (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
     371                                &OS2HwndFrame);
    372372
    373373  if(OS2Hwnd == 0) {
    374         dprintf(("Window creation failed!!"));
    375         return FALSE;
     374        dprintf(("Window creation failed!!"));
     375        return FALSE;
    376376  }
    377377
    378378  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    379         dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
    380         return FALSE;
     379        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
     380        return FALSE;
    381381  }
    382382  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    383         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    384         return FALSE;
     383        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     384        return FALSE;
    385385  }
    386386#if 0
    387387  if(OS2Hwnd != OS2HwndFrame) {
    388388    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    389             dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
    390             return FALSE;
     389            dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
     390            return FALSE;
    391391    }
    392392    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    393             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    394             return FALSE;
     393            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     394            return FALSE;
    395395    }
    396396  }
     
    400400  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
    401401  {
    402         if (cs->hMenu) SetMenu(cs->hMenu);
    403         else
    404         {
    405                 if (windowClass->getMenuNameA()) {
    406                         cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
    407                         if (cs->hMenu) SetMenu(cs->hMenu );
    408                 }
    409         }
    410   }
    411   else  windowId = (UINT)cs->hMenu;
     402        if (cs->hMenu) SetMenu(cs->hMenu);
     403        else
     404        {
     405                if (windowClass->getMenuNameA()) {
     406                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
     407                        if (cs->hMenu) SetMenu(cs->hMenu );
     408                }
     409        }
     410  }
     411  else  windowId = (UINT)cs->hMenu;
    412412
    413413  //Set icon from class
    414414  if(windowClass->getIcon())
    415         SetIcon(windowClass->getIcon());
     415        SetIcon(windowClass->getIcon());
    416416
    417417  if(getParent()) {
    418         SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
    419                      rectClient.right-rectClient.left,
    420                      rectClient.bottom-rectClient.top,
    421                      SWP_NOACTIVATE | SWP_NOZORDER);
     418        SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
     419                     rectClient.right-rectClient.left,
     420                     rectClient.bottom-rectClient.top,
     421                     SWP_NOACTIVATE | SWP_NOZORDER);
    422422  }
    423423  else {
    424         SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
    425                      rectClient.right-rectClient.left,
    426                      rectClient.bottom-rectClient.top,
    427                      SWP_NOACTIVATE);
     424        SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
     425                     rectClient.right-rectClient.left,
     426                     rectClient.bottom-rectClient.top,
     427                     SWP_NOACTIVATE);
    428428  }
    429429  //Get the client window rectangle
     
    439439  if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) )
    440440  {
    441         //doesn't work right, messes up client rectangle
     441        //doesn't work right, messes up client rectangle
    442442#if 0
    443         SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
     443        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
    444444#endif
    445         OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    446         dprintf(("Sending WM_CREATE"));
    447         if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
    448         {
    449             if(!(flags & WIN_NEED_SIZE)) {
    450                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    451                                 MAKELONG(rectClient.right-rectClient.left,
    452                                         rectClient.bottom-rectClient.top));
    453                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    454             }
    455             if (cs->style & WS_VISIBLE) ShowWindow( sw );
     445        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
     446        dprintf(("Sending WM_CREATE"));
     447        if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
     448        {
     449            if(!(flags & WIN_NEED_SIZE)) {
     450                SendMessageA(WM_SIZE, SIZE_RESTORED,
     451                                MAKELONG(rectClient.right-rectClient.left,
     452                                        rectClient.bottom-rectClient.top));
     453                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     454            }
     455            if (cs->style & WS_VISIBLE) ShowWindow( sw );
    456456
    457457#if 0
    458             /* Call WH_SHELL hook */
    459 
    460             if (!(dwStyle & WS_CHILD) && !owner)
    461                 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
     458            /* Call WH_SHELL hook */
     459
     460            if (!(dwStyle & WS_CHILD) && !owner)
     461                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
    462462#endif
    463             SetLastError(0);
    464             return TRUE;
    465         }
     463            SetLastError(0);
     464            return TRUE;
     465        }
    466466  }
    467467  fCreated = FALSE;
     
    473473#if 0
    474474/***********************************************************************
    475  *           WINPOS_MinMaximize
     475 *           WINPOS_MinMaximize
    476476 *
    477477 * Fill in lpRect and return additional flags to be used with SetWindowPos().
     
    492492    if( dwStyle & WS_MINIMIZE )
    493493    {
    494         if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
    495         return (SWP_NOSIZE | SWP_NOMOVE);
    496         swpFlags |= SWP_NOCOPYBITS;
     494        if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
     495        return (SWP_NOSIZE | SWP_NOMOVE);
     496        swpFlags |= SWP_NOCOPYBITS;
    497497    }
    498498    switch( cmd )
    499499    {
    500         case SW_MINIMIZE:
    501         if( dwStyle & WS_MAXIMIZE)
    502         {
    503              flags |= WIN_RESTORE_MAX;
    504              dwStyle &= ~WS_MAXIMIZE;
    505                 }
    506                 else
    507              flags &= ~WIN_RESTORE_MAX;
    508              dwStyle |= WS_MINIMIZE;
     500        case SW_MINIMIZE:
     501        if( dwStyle & WS_MAXIMIZE)
     502        {
     503             flags |= WIN_RESTORE_MAX;
     504             dwStyle &= ~WS_MAXIMIZE;
     505                }
     506                else
     507             flags &= ~WIN_RESTORE_MAX;
     508             dwStyle |= WS_MINIMIZE;
    509509
    510510#if 0
    511         if( flags & WIN_NATIVE )
    512              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
    513              swpFlags |= MINMAX_NOSWP;
     511        if( flags & WIN_NATIVE )
     512             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
     513             swpFlags |= MINMAX_NOSWP;
    514514#endif
    515515
    516         lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
    517 
    518         SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
    519              GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
    520         swpFlags |= SWP_NOCOPYBITS;
    521         break;
    522 
    523         case SW_MAXIMIZE:
    524                 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
    525 
    526         if( dwStyle & WS_MINIMIZE )
    527         {
    528              if( flags & WIN_NATIVE )
    529              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    530                 swpFlags |= MINMAX_NOSWP;
    531 
    532              WINPOS_ShowIconTitle( wndPtr, FALSE );
    533              dwStyle &= ~WS_MINIMIZE;
    534         }
    535                 dwStyle |= WS_MAXIMIZE;
    536 
    537         SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
    538                     size.x, size.y );
    539         break;
    540 
    541         case SW_RESTORE:
    542         if( dwStyle & WS_MINIMIZE )
    543         {
    544              if( flags & WIN_NATIVE )
    545              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    546                 swpFlags |= MINMAX_NOSWP;
    547 
    548              dwStyle &= ~WS_MINIMIZE;
    549              WINPOS_ShowIconTitle( wndPtr, FALSE );
    550 
    551              if( flags & WIN_RESTORE_MAX)
    552              {
    553              /* Restore to maximized position */
    554                         CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
    555                         WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
    556                         CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
    557              dwStyle |= WS_MAXIMIZE;
    558              SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
    559              break;
    560              }
    561         }
    562         else
    563              if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
    564              else dwStyle &= ~WS_MAXIMIZE;
    565 
    566         /* Restore to normal position */
    567 
    568         *lpRect = lpPos->rectNormal;
    569         lpRect->right -= lpRect->left;
    570         lpRect->bottom -= lpRect->top;
    571 
    572         break;
     516        lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
     517
     518        SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
     519             GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     520        swpFlags |= SWP_NOCOPYBITS;
     521        break;
     522
     523        case SW_MAXIMIZE:
     524                WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
     525
     526        if( dwStyle & WS_MINIMIZE )
     527        {
     528             if( flags & WIN_NATIVE )
     529             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     530                swpFlags |= MINMAX_NOSWP;
     531
     532             WINPOS_ShowIconTitle( wndPtr, FALSE );
     533             dwStyle &= ~WS_MINIMIZE;
     534        }
     535                dwStyle |= WS_MAXIMIZE;
     536
     537        SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
     538                    size.x, size.y );
     539        break;
     540
     541        case SW_RESTORE:
     542        if( dwStyle & WS_MINIMIZE )
     543        {
     544             if( flags & WIN_NATIVE )
     545             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     546                swpFlags |= MINMAX_NOSWP;
     547
     548             dwStyle &= ~WS_MINIMIZE;
     549             WINPOS_ShowIconTitle( wndPtr, FALSE );
     550
     551             if( flags & WIN_RESTORE_MAX)
     552             {
     553             /* Restore to maximized position */
     554                        CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
     555                        WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
     556                        CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
     557             dwStyle |= WS_MAXIMIZE;
     558             SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
     559             break;
     560             }
     561        }
     562        else
     563             if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
     564             else dwStyle &= ~WS_MAXIMIZE;
     565
     566        /* Restore to normal position */
     567
     568        *lpRect = lpPos->rectNormal;
     569        lpRect->right -= lpRect->left;
     570        lpRect->bottom -= lpRect->top;
     571
     572        break;
    573573    }
    574574    } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
     
    577577#endif
    578578/*******************************************************************
    579  *           GetMinMaxInfo
     579 *           GetMinMaxInfo
    580580 *
    581581 * Get the minimized and maximized information for a window.
    582582 */
    583583void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
    584                                 POINT *minTrack, POINT *maxTrack )
     584                                POINT *minTrack, POINT *maxTrack )
    585585{
    586586    MINMAXINFO MinMax;
     
    599599    else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
    600600    {
    601         xinc = GetSystemMetrics(SM_CXDLGFRAME);
    602         yinc = GetSystemMetrics(SM_CYDLGFRAME);
     601        xinc = GetSystemMetrics(SM_CXDLGFRAME);
     602        yinc = GetSystemMetrics(SM_CYDLGFRAME);
    603603    }
    604604    else
    605605    {
    606         xinc = yinc = 0;
    607         if (HAS_THICKFRAME(dwStyle))
    608         {
    609             xinc += GetSystemMetrics(SM_CXFRAME);
    610             yinc += GetSystemMetrics(SM_CYFRAME);
    611         }
    612         if (dwStyle & WS_BORDER)
    613         {
    614             xinc += GetSystemMetrics(SM_CXBORDER);
    615             yinc += GetSystemMetrics(SM_CYBORDER);
    616         }
     606        xinc = yinc = 0;
     607        if (HAS_THICKFRAME(dwStyle))
     608        {
     609            xinc += GetSystemMetrics(SM_CXFRAME);
     610            yinc += GetSystemMetrics(SM_CYFRAME);
     611        }
     612        if (dwStyle & WS_BORDER)
     613        {
     614            xinc += GetSystemMetrics(SM_CXBORDER);
     615            yinc += GetSystemMetrics(SM_CYBORDER);
     616        }
    617617    }
    618618    MinMax.ptMaxSize.x += 2 * xinc;
     
    622622    lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
    623623    if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
    624         CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
     624        CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
    625625    else
    626626    {
    627627#endif
    628         MinMax.ptMaxPosition.x = -xinc;
    629         MinMax.ptMaxPosition.y = -yinc;
     628        MinMax.ptMaxPosition.x = -xinc;
     629        MinMax.ptMaxPosition.y = -yinc;
    630630//    }
    631631
     
    635635
    636636    dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
    637                       MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
    638                       MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
    639                       MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
    640                       MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
     637                      MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
     638                      MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
     639                      MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
     640                      MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
    641641    MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
    642                                    MinMax.ptMinTrackSize.x );
     642                                   MinMax.ptMinTrackSize.x );
    643643    MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
    644                                    MinMax.ptMinTrackSize.y );
     644                                   MinMax.ptMinTrackSize.y );
    645645
    646646    if (maxSize)    *maxSize  = MinMax.ptMaxSize;
     
    650650}
    651651/***********************************************************************
    652  *           WINPOS_SendNCCalcSize
     652 *           WINPOS_SendNCCalcSize
    653653 *
    654654 * Send a WM_NCCALCSIZE message to a window.
     
    658658 */
    659659LONG Win32Window::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect,
    660                                 RECT *oldClientRect, WINDOWPOS *winpos,
    661                                 RECT *newClientRect )
     660                                RECT *oldClientRect, WINDOWPOS *winpos,
     661                                RECT *newClientRect )
    662662{
    663663   NCCALCSIZE_PARAMS params;
     
    668668   if (calcValidRect)
    669669   {
    670         winposCopy = *winpos;
    671         params.rgrc[1] = *oldWindowRect;
    672         params.rgrc[2] = *oldClientRect;
    673         params.lppos = &winposCopy;
     670        winposCopy = *winpos;
     671        params.rgrc[1] = *oldWindowRect;
     672        params.rgrc[2] = *oldClientRect;
     673        params.lppos = &winposCopy;
    674674   }
    675675   result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect,
    676                                 (LPARAM)&params );
     676                                (LPARAM)&params );
    677677   *newClientRect = params.rgrc[0];
    678678   return result;
     
    696696{
    697697  if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
    698         return 0; //app handles this message
     698        return 0; //app handles this message
    699699  }
    700700  delete this;
     
    726726//******************************************************************************
    727727//******************************************************************************
     728ULONG Win32Window::MsgPosChanging(LPARAM lp)
     729{
     730    dprintf(("MsgPosChanging"));
     731#if 1
     732    if(fCreated == FALSE) {
     733        return 1;
     734    }
     735#endif
     736    return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
     737}
     738//******************************************************************************
     739//******************************************************************************
     740ULONG Win32Window::MsgPosChanged(LPARAM lp)
     741{
     742    dprintf(("MsgPosChanged"));
     743#if 1
     744    if(fCreated == FALSE) {
     745        return 1;
     746    }
     747#endif
     748    return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
     749}
     750//******************************************************************************
     751//******************************************************************************
    728752ULONG Win32Window::MsgMove(ULONG x, ULONG y)
    729753{
    730754    dprintf(("MsgMove to (%d,%d)", x, y));
    731755    if(fCreated == FALSE) {
    732         return 1;
     756        return 1;
    733757    }
    734758
     
    741765  switch(cmd) {
    742766    case CMD_MENU:
    743         return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
     767        return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
    744768    case CMD_CONTROL:
    745         return 0; //todo
     769        return 0; //todo
    746770    case CMD_ACCELERATOR:
    747         dprintf(("accelerator command"));
    748         return 0; //todo
     771        dprintf(("accelerator command"));
     772        return 0; //todo
    749773  }
    750774  return 0;
     
    765789
    766790    if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?)
    767         return 1;
     791        return 1;
    768792    }
    769793
    770794    if(fMinimize) {
    771             fwSizeType = SIZE_MINIMIZED;
     795            fwSizeType = SIZE_MINIMIZED;
    772796    }
    773797    else
    774798    if(fMaximize) {
    775             fwSizeType = SIZE_MAXIMIZED;
     799            fwSizeType = SIZE_MAXIMIZED;
    776800    }
    777801    else    fwSizeType = SIZE_RESTORED;
     
    785809    if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE)
    786810    {
    787         if(!fActivate) {
    788             return 1;
    789         }
     811        if(!fActivate) {
     812            return 1;
     813        }
    790814    }
    791815    return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd);
     
    807831    lParam |= (scancode << 16);
    808832    if(keyflags & KEY_ALTDOWN)
    809         lParam |= (1<<29);
     833        lParam |= (1<<29);
    810834    if(keyflags & KEY_PREVDOWN)
    811         lParam |= (1<<30);
     835        lParam |= (1<<30);
    812836    if(keyflags & KEY_UP)
    813         lParam |= (1<<31);
     837        lParam |= (1<<31);
    814838    if(keyflags & KEY_DEADKEY) {
    815         dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    816         return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
     839        dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     840        return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
    817841    }
    818842    else {
    819         dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    820         return SendInternalMessageA(WM_CHAR, cmd, lParam);
     843        dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     844        return SendInternalMessageA(WM_CHAR, cmd, lParam);
    821845    }
    822846}
     
    826850{
    827851    if(hwnd == 0) {
    828         //other app lost focus
    829         SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
     852        //other app lost focus
     853        SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
    830854    }
    831855    return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
     
    836860{
    837861    if(hwnd == 0) {
    838         //other app lost focus
    839         SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
     862        //other app lost focus
     863        SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
    840864    }
    841865    return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
     
    850874    dprintf(("MsgButton to (%d,%d)", ncx, ncy));
    851875    switch(msg) {
    852         case BUTTON_LEFTDOWN:
    853                 win32msg = WM_LBUTTONDOWN;
    854                 win32ncmsg = WM_NCLBUTTONDOWN;
    855                 break;
    856         case BUTTON_LEFTUP:
    857                 win32msg = WM_LBUTTONUP;
    858                 win32ncmsg = WM_NCLBUTTONUP;
    859                 break;
    860         case BUTTON_LEFTDBLCLICK:
    861                 win32msg = WM_LBUTTONDBLCLK;
    862                 win32ncmsg = WM_NCLBUTTONDBLCLK;
    863                 break;
    864         case BUTTON_RIGHTUP:
    865                 win32msg = WM_RBUTTONUP;
    866                 win32ncmsg = WM_NCRBUTTONUP;
    867                 break;
    868         case BUTTON_RIGHTDOWN:
    869                 win32msg = WM_RBUTTONDOWN;
    870                 win32ncmsg = WM_NCRBUTTONDOWN;
    871                 break;
    872         case BUTTON_RIGHTDBLCLICK:
    873                 win32msg = WM_RBUTTONDBLCLK;
    874                 win32ncmsg = WM_NCRBUTTONDBLCLK;
    875                 break;
    876         case BUTTON_MIDDLEUP:
    877                 win32msg = WM_MBUTTONUP;
    878                 win32ncmsg = WM_NCMBUTTONUP;
    879                 break;
    880         case BUTTON_MIDDLEDOWN:
    881                 win32msg = WM_MBUTTONDOWN;
    882                 win32ncmsg = WM_NCMBUTTONDOWN;
    883                 break;
    884         case BUTTON_MIDDLEDBLCLICK:
    885                 win32msg = WM_MBUTTONDBLCLK;
    886                 win32ncmsg = WM_NCMBUTTONDBLCLK;
    887                 break;
    888         default:
    889                 dprintf(("Win32Window::Button: invalid msg!!!!"));
    890                 return 1;
     876        case BUTTON_LEFTDOWN:
     877                win32msg = WM_LBUTTONDOWN;
     878                win32ncmsg = WM_NCLBUTTONDOWN;
     879                break;
     880        case BUTTON_LEFTUP:
     881                win32msg = WM_LBUTTONUP;
     882                win32ncmsg = WM_NCLBUTTONUP;
     883                break;
     884        case BUTTON_LEFTDBLCLICK:
     885                win32msg = WM_LBUTTONDBLCLK;
     886                win32ncmsg = WM_NCLBUTTONDBLCLK;
     887                break;
     888        case BUTTON_RIGHTUP:
     889                win32msg = WM_RBUTTONUP;
     890                win32ncmsg = WM_NCRBUTTONUP;
     891                break;
     892        case BUTTON_RIGHTDOWN:
     893                win32msg = WM_RBUTTONDOWN;
     894                win32ncmsg = WM_NCRBUTTONDOWN;
     895                break;
     896        case BUTTON_RIGHTDBLCLICK:
     897                win32msg = WM_RBUTTONDBLCLK;
     898                win32ncmsg = WM_NCRBUTTONDBLCLK;
     899                break;
     900        case BUTTON_MIDDLEUP:
     901                win32msg = WM_MBUTTONUP;
     902                win32ncmsg = WM_NCMBUTTONUP;
     903                break;
     904        case BUTTON_MIDDLEDOWN:
     905                win32msg = WM_MBUTTONDOWN;
     906                win32ncmsg = WM_NCMBUTTONDOWN;
     907                break;
     908        case BUTTON_MIDDLEDBLCLICK:
     909                win32msg = WM_MBUTTONDBLCLK;
     910                win32ncmsg = WM_NCMBUTTONDBLCLK;
     911                break;
     912        default:
     913                dprintf(("Win32Window::Button: invalid msg!!!!"));
     914                return 1;
    891915    }
    892916    if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) {
    893         if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
    894             return 1;
    895         }
     917        if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
     918            return 1;
     919        }
    896920    }
    897921    SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
     
    905929
    906930    if(keystate & WMMOVE_LBUTTON)
    907         winstate |= MK_LBUTTON;
     931        winstate |= MK_LBUTTON;
    908932    if(keystate & WMMOVE_RBUTTON)
    909         winstate |= MK_RBUTTON;
     933        winstate |= MK_RBUTTON;
    910934    if(keystate & WMMOVE_MBUTTON)
    911         winstate |= MK_MBUTTON;
     935        winstate |= MK_MBUTTON;
    912936    if(keystate & WMMOVE_SHIFT)
    913         winstate |= MK_SHIFT;
     937        winstate |= MK_SHIFT;
    914938    if(keystate & WMMOVE_CTRL)
    915         winstate |= MK_CONTROL;
     939        winstate |= MK_CONTROL;
    916940
    917941    return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
     
    925949//******************************************************************************
    926950//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
    927 //      (or are we simply erasing too much here)
     951//      (or are we simply erasing too much here)
    928952//******************************************************************************
    929953ULONG Win32Window::MsgEraseBackGround(HDC hdc)
    930954{
    931955    if(isIcon) {
    932             return SendInternalMessageA(WM_ICONERASEBKGND, hdc, 0);
     956            return SendInternalMessageA(WM_ICONERASEBKGND, hdc, 0);
    933957    }
    934958    else    return SendInternalMessageA(WM_ERASEBKGND, hdc, 0);
     
    939963{
    940964    if(isUnicode) {
    941             return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
     965            return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
    942966    }
    943967    else    return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
     
    955979{
    956980    if(isUnicode) {
    957         SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW);
     981        SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW);
    958982    }
    959983    else {
    960         SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA);
     984        SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA);
    961985    }
    962986    return windowNameA;
     
    969993    {
    970994    case WM_GETTEXTLENGTH:
    971         return wndNameLength;
     995        return wndNameLength;
    972996
    973997    case WM_GETTEXT:   //TODO: SS_ICON controls
    974         strncpy((LPSTR)lParam, windowNameA, wParam);
    975         return min(wndNameLength, wParam);
     998        strncpy((LPSTR)lParam, windowNameA, wParam);
     999        return min(wndNameLength, wParam);
    9761000
    9771001    case WM_SETTEXT:
    978         return 0;
     1002        return 0;
    9791003
    9801004    case WM_SETREDRAW:
    981         if(wParam)
    982                 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
    983         else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
    984 
    985         return 0; //TODO
     1005        if(wParam)
     1006                SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
     1007        else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
     1008
     1009        return 0; //TODO
    9861010
    9871011    case WM_NCCREATE:
    988         return(TRUE);
     1012        return(TRUE);
    9891013
    9901014    case WM_CTLCOLORMSGBOX:
     
    9951019    case WM_CTLCOLORSTATIC:
    9961020    case WM_CTLCOLORSCROLLBAR:
    997         SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
    998         SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
    999         return GetSysColorBrush(COLOR_BTNFACE);
     1021        SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
     1022        SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
     1023        return GetSysColorBrush(COLOR_BTNFACE);
    10001024
    10011025    case WM_PARENTNOTIFY:
    1002         return 0;
     1026        return 0;
    10031027
    10041028    case WM_MOUSEACTIVATE:
    10051029    {
    1006         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1007         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1008         dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1009         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1010         {
    1011             if(getParent()) {
    1012                 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
    1013                 if(rc)  return rc;
    1014             }
    1015         }
    1016         return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
     1030        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1031        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1032        dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1033        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1034        {
     1035            if(getParent()) {
     1036                LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
     1037                if(rc)  return rc;
     1038            }
     1039        }
     1040        return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
    10171041    }
    10181042    case WM_SETCURSOR:
    10191043    {
    1020         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1021         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1022         dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1023         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1024         {
    1025             if(getParent()) {
    1026                 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
    1027                 if(rc)  return rc;
    1028             }
    1029         }
    1030         return 1;
     1044        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1045        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1046        dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1047        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1048        {
     1049            if(getParent()) {
     1050                LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
     1051                if(rc)  return rc;
     1052            }
     1053        }
     1054        return 1;
    10311055    }
    10321056    case WM_MOUSEMOVE:
    1033         return 0;
    1034 
     1057        return 0;
     1058
     1059    case WM_WINDOWPOSCHANGED:
     1060    {
     1061
     1062/* undocumented SWP flags - from SDK 3.1 */
     1063#define SWP_NOCLIENTSIZE        0x0800
     1064#define SWP_NOCLIENTMOVE        0x1000
     1065
     1066        PWINDOWPOS wpos = (PWINDOWPOS)lParam;
     1067        WPARAM     wp   = SIZE_RESTORED;
     1068
     1069        if (!(wpos->flags & SWP_NOCLIENTMOVE))
     1070            SendMessageA(WM_MOVE, 0, MAKELONG(wpos->x, wpos->y));
     1071
     1072        if (!(wpos->flags & SWP_NOCLIENTSIZE))
     1073        {
     1074            if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
     1075            else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
     1076
     1077            SendMessageA(WM_SIZE, wp, MAKELONG(wpos->cx,wpos->cy));
     1078        }
     1079        return 0;
     1080    }
    10351081    case WM_ERASEBKGND:
    10361082    case WM_ICONERASEBKGND:
     
    10381084      RECT rect;
    10391085
    1040         if (!windowClass->getBackgroundBrush()) return 0;
    1041 
    1042         /*  Since WM_ERASEBKGND may receive either a window dc or a    */
    1043         /*  client dc, the area to be erased has to be retrieved from  */
    1044         /*  the device context.                                    */
    1045         GetClipBox( (HDC)wParam, &rect );
    1046 
    1047         FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
    1048 
    1049         return 1;
     1086        if (!windowClass->getBackgroundBrush()) return 0;
     1087
     1088        /*  Since WM_ERASEBKGND may receive either a window dc or a    */
     1089        /*  client dc, the area to be erased has to be retrieved from  */
     1090        /*  the device context.                                    */
     1091        GetClipBox( (HDC)wParam, &rect );
     1092
     1093        FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
     1094
     1095        return 1;
    10501096    }
    10511097
     
    10591105    case WM_NCMBUTTONUP:
    10601106    case WM_NCMBUTTONDBLCLK:
    1061         return 0;           //TODO: Send WM_SYSCOMMAND if required
     1107        return 0;           //TODO: Send WM_SYSCOMMAND if required
    10621108
    10631109    case WM_NCHITTEST: //TODO:
    1064         return 0;
     1110        return 0;
    10651111
    10661112    default:
    1067         return 1;
     1113        return 1;
    10681114    }
    10691115}
     
    10751121    {
    10761122    case WM_GETTEXTLENGTH:
    1077         return wndNameLength;
     1123        return wndNameLength;
    10781124
    10791125    case WM_GETTEXT:   //TODO: SS_ICON controls
    1080         lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
    1081         return min(wndNameLength, wParam);
     1126        lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
     1127        return min(wndNameLength, wParam);
    10821128
    10831129    default:
    1084         return DefWindowProcA(Msg, wParam, lParam);
     1130        return DefWindowProcA(Msg, wParam, lParam);
    10851131    }
    10861132}
     
    10901136{
    10911137  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1092         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1138        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    10931139
    10941140  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1095         return(0);
     1141        return(0);
    10961142  }
    10971143  switch(Msg)
    10981144  {
    1099         case WM_CREATE:
    1100         {
    1101                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1102                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1103                         return(-1); //don't create window
    1104                 }
    1105                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
    1106                         dprintf(("WM_CREATE returned -1\n"));
    1107                         return(-1); //don't create window
    1108                 }
    1109                 NotifyParent(Msg, wParam, lParam);
    1110 
    1111                 return(0);
    1112         }
    1113         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1114                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1115 
    1116         case WM_LBUTTONDOWN:
    1117         case WM_MBUTTONDOWN:
    1118         case WM_RBUTTONDOWN:
    1119                 NotifyParent(Msg, wParam, lParam);
    1120                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1121 
    1122         case WM_DESTROY:
    1123                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1124                 NotifyParent(Msg, wParam, lParam);
    1125                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1126         default:
    1127                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1145        case WM_CREATE:
     1146        {
     1147                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1148                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1149                        return(-1); //don't create window
     1150                }
     1151                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
     1152                        dprintf(("WM_CREATE returned -1\n"));
     1153                        return(-1); //don't create window
     1154                }
     1155                NotifyParent(Msg, wParam, lParam);
     1156
     1157                return(0);
     1158        }
     1159        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1160                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1161
     1162        case WM_LBUTTONDOWN:
     1163        case WM_MBUTTONDOWN:
     1164        case WM_RBUTTONDOWN:
     1165                NotifyParent(Msg, wParam, lParam);
     1166                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1167
     1168        case WM_DESTROY:
     1169                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1170                NotifyParent(Msg, wParam, lParam);
     1171                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1172        default:
     1173                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    11281174  }
    11291175}
     
    11331179{
    11341180  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1135         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1181        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    11361182
    11371183  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1138         return(0);
     1184        return(0);
    11391185  }
    11401186  switch(Msg)
    11411187  {
    1142         case WM_CREATE:
    1143         {
    1144                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1145                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1146                         return(0); //don't create window
    1147                 }
    1148                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1149                         dprintf(("WM_CREATE returned FALSE\n"));
    1150                         return(0); //don't create window
    1151                 }
    1152                 NotifyParent(Msg, wParam, lParam);
    1153 
    1154                 return(1);
    1155         }
    1156         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1157                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1158 
    1159         case WM_LBUTTONDOWN:
    1160         case WM_MBUTTONDOWN:
    1161         case WM_RBUTTONDOWN:
    1162                 NotifyParent(Msg, wParam, lParam);
    1163                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1164 
    1165         case WM_DESTROY:
    1166                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1167                 NotifyParent(Msg, wParam, lParam);
    1168                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1169 
    1170         default:
    1171                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1188        case WM_CREATE:
     1189        {
     1190                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1191                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1192                        return(0); //don't create window
     1193                }
     1194                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1195                        dprintf(("WM_CREATE returned FALSE\n"));
     1196                        return(0); //don't create window
     1197                }
     1198                NotifyParent(Msg, wParam, lParam);
     1199
     1200                return(1);
     1201        }
     1202        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1203                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1204
     1205        case WM_LBUTTONDOWN:
     1206        case WM_MBUTTONDOWN:
     1207        case WM_RBUTTONDOWN:
     1208                NotifyParent(Msg, wParam, lParam);
     1209                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1210
     1211        case WM_DESTROY:
     1212                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1213                NotifyParent(Msg, wParam, lParam);
     1214                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1215
     1216        default:
     1217                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    11721218  }
    11731219}
     
    11781224{
    11791225  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1180         dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1226        dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    11811227
    11821228  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1183         return(0);
     1229        return(0);
    11841230  }
    11851231  switch(Msg)
    11861232  {
    1187         case WM_CREATE:
    1188         {
    1189                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1190                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1191                         return(0); //don't create window
    1192                 }
    1193                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1194                         dprintf(("WM_CREATE returned FALSE\n"));
    1195                         return(0); //don't create window
    1196                 }
    1197                 NotifyParent(Msg, wParam, lParam);
    1198 
    1199                 return(1);
    1200         }
    1201         case WM_LBUTTONDOWN:
    1202         case WM_MBUTTONDOWN:
    1203         case WM_RBUTTONDOWN:
    1204                 NotifyParent(Msg, wParam, lParam);
    1205                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1206 
    1207         case WM_DESTROY:
    1208                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1209                 NotifyParent(Msg, wParam, lParam);
    1210                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1211         default:
    1212                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1233        case WM_CREATE:
     1234        {
     1235                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1236                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1237                        return(0); //don't create window
     1238                }
     1239                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1240                        dprintf(("WM_CREATE returned FALSE\n"));
     1241                        return(0); //don't create window
     1242                }
     1243                NotifyParent(Msg, wParam, lParam);
     1244
     1245                return(1);
     1246        }
     1247        case WM_LBUTTONDOWN:
     1248        case WM_MBUTTONDOWN:
     1249        case WM_RBUTTONDOWN:
     1250                NotifyParent(Msg, wParam, lParam);
     1251                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1252
     1253        case WM_DESTROY:
     1254                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1255                NotifyParent(Msg, wParam, lParam);
     1256                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1257        default:
     1258                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12131259  }
    12141260}
     
    12201266{
    12211267  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1222         dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1268        dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    12231269
    12241270  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1225         return(0);
     1271        return(0);
    12261272  }
    12271273  switch(Msg)
    12281274  {
    1229         case WM_CREATE:
    1230         {
    1231                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1232                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1233                         return(0); //don't create window
    1234                 }
    1235                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1236                         dprintf(("WM_CREATE returned FALSE\n"));
    1237                         return(0); //don't create window
    1238                 }
    1239                 NotifyParent(Msg, wParam, lParam);
    1240 
    1241                 return(1);
    1242         }
    1243         case WM_LBUTTONDOWN:
    1244         case WM_MBUTTONDOWN:
    1245         case WM_RBUTTONDOWN:
    1246                 NotifyParent(Msg, wParam, lParam);
    1247                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1248 
    1249         case WM_DESTROY:
    1250                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1251                 NotifyParent(Msg, wParam, lParam);
    1252                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1253         default:
    1254                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1275        case WM_CREATE:
     1276        {
     1277                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1278                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1279                        return(0); //don't create window
     1280                }
     1281                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1282                        dprintf(("WM_CREATE returned FALSE\n"));
     1283                        return(0); //don't create window
     1284                }
     1285                NotifyParent(Msg, wParam, lParam);
     1286
     1287                return(1);
     1288        }
     1289        case WM_LBUTTONDOWN:
     1290        case WM_MBUTTONDOWN:
     1291        case WM_RBUTTONDOWN:
     1292                NotifyParent(Msg, wParam, lParam);
     1293                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1294
     1295        case WM_DESTROY:
     1296                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1297                NotifyParent(Msg, wParam, lParam);
     1298                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1299        default:
     1300                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12551301  }
    12561302}
     
    12661312    return 0;
    12671313  }
    1268   postmsg->Msg    = msg;
     1314  postmsg->Msg    = msg;
    12691315  postmsg->wParam = wParam;
    12701316  postmsg->lParam = lParam;
     
    12821328    return 0;
    12831329  }
    1284   postmsg->Msg    = msg;
     1330  postmsg->Msg    = msg;
    12851331  postmsg->wParam = wParam;
    12861332  postmsg->lParam = lParam;
     
    12971343   while(window)
    12981344   {
    1299         if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
    1300         {
    1301                 /* Notify the parent window only */
    1302                 parentwindow = window->getParent();
    1303                 if(parentwindow) {
    1304                         if(Msg == WM_CREATE || Msg == WM_DESTROY) {
    1305                                 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
    1306                         }
    1307                         else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
    1308                 }
    1309         }
    1310         else    break;
    1311 
    1312         window = parentwindow;
     1345        if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
     1346        {
     1347                /* Notify the parent window only */
     1348                parentwindow = window->getParent();
     1349                if(parentwindow) {
     1350                        if(Msg == WM_CREATE || Msg == WM_DESTROY) {
     1351                                parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
     1352                        }
     1353                        else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
     1354                }
     1355        }
     1356        else    break;
     1357
     1358        window = parentwindow;
    13131359   }
    13141360}
     
    13171363BOOL Win32Window::SetMenu(HMENU hMenu)
    13181364{
    1319  PVOID          menutemplate;
     1365 PVOID          menutemplate;
    13201366 Win32Resource *winres = (Win32Resource *)hMenu;
    13211367
    13221368    dprintf(("SetMenu %x", hMenu));
    13231369    if(HIWORD(winres) == 0) {
    1324         dprintf(("Win32Window:: Win32Resource *winres == 0"));
    1325         SetLastError(ERROR_INVALID_PARAMETER);
    1326         return FALSE;
     1370        dprintf(("Win32Window:: Win32Resource *winres == 0"));
     1371        SetLastError(ERROR_INVALID_PARAMETER);
     1372        return FALSE;
    13271373    }
    13281374    menutemplate = winres->lockOS2Resource();
    13291375    if(menutemplate == NULL)
    13301376    {
    1331         dprintf(("Win32Window::SetMenu menutemplate == 0"));
    1332         return FALSE;
     1377        dprintf(("Win32Window::SetMenu menutemplate == 0"));
     1378        return FALSE;
    13331379    }
    13341380    OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate);
    13351381    if(OS2HwndMenu == 0) {
    1336         dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
    1337         return FALSE;
     1382        dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
     1383        return FALSE;
    13381384    }
    13391385    menuResource = winres;
     
    13451391{
    13461392 Win32Resource *winres = (Win32Resource *)hAccel;
    1347  HANDLE         accelhandle;
     1393 HANDLE         accelhandle;
    13481394
    13491395    if(HIWORD(hAccel) == 0) {
    1350         dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
    1351         SetLastError(ERROR_INVALID_PARAMETER);
    1352         return FALSE;
     1396        dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
     1397        SetLastError(ERROR_INVALID_PARAMETER);
     1398        return FALSE;
    13531399    }
    13541400    acceltableResource = winres;
     
    13721418    dprintf(("ShowWindow %x", nCmdShow));
    13731419    if(fFirstShow) {
    1374         if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
    1375                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    1376                                 MAKELONG(rectClient.right-rectClient.left,
    1377                                         rectClient.bottom-rectClient.top));
    1378                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    1379 
    1380         }
    1381         fFirstShow = FALSE;
     1420        if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
     1421                SendMessageA(WM_SIZE, SIZE_RESTORED,
     1422                                MAKELONG(rectClient.right-rectClient.left,
     1423                                        rectClient.bottom-rectClient.top));
     1424                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     1425
     1426        }
     1427        fFirstShow = FALSE;
    13821428    }
    13831429    switch(nCmdShow)
     
    13851431    case SW_SHOW:
    13861432    case SW_SHOWDEFAULT: //todo
    1387         showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
    1388         break;
     1433        showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
     1434        break;
    13891435    case SW_HIDE:
    1390         showstate = SWPOS_HIDE;
    1391         break;
     1436        showstate = SWPOS_HIDE;
     1437        break;
    13921438    case SW_RESTORE:
    1393         showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1394         break;
     1439        showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1440        break;
    13951441    case SW_MINIMIZE:
    1396         showstate = SWPOS_MINIMIZE;
    1397         break;
     1442        showstate = SWPOS_MINIMIZE;
     1443        break;
    13981444    case SW_SHOWMAXIMIZED:
    1399         showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1400         break;
     1445        showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1446        break;
    14011447    case SW_SHOWMINIMIZED:
    1402         showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1403         break;
     1448        showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1449        break;
    14041450    case SW_SHOWMINNOACTIVE:
    1405         showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
    1406         break;
     1451        showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
     1452        break;
    14071453    case SW_SHOWNA:
    1408         showstate = SWPOS_SHOW;
    1409         break;
     1454        showstate = SWPOS_SHOW;
     1455        break;
    14101456    case SW_SHOWNOACTIVATE:
    1411         showstate = SWPOS_SHOW;
    1412         break;
     1457        showstate = SWPOS_SHOW;
     1458        break;
    14131459    case SW_SHOWNORMAL:
    1414         showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
    1415         break;
     1460        showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
     1461        break;
    14161462    }
    14171463    return OSLibWinShowWindow(OS2HwndFrame, showstate);
     
    14211467BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
    14221468{
    1423  Win32Window *window;
    1424  ULONG        setstate = 0;
    1425 
    1426     switch(hwndInsertAfter) {
    1427     case HWND_BOTTOM:
    1428         hwndInsertAfter = HWNDOS_BOTTOM;
    1429         break;
    1430     case HWND_TOPMOST: //TODO
    1431     case HWND_NOTOPMOST: //TODO:
    1432     case HWND_TOP:
    1433         hwndInsertAfter = HWNDOS_TOP;
    1434         break;
    1435     default:
    1436         window = GetWindowFromHandle(hwndInsertAfter);
    1437         if(window) {
    1438             hwndInsertAfter = window->getOS2WindowHandle();
    1439             PRECT clientRect = window->getClientRect();
    1440 
    1441 #if 1
    1442             if(x+cx > clientRect->right - clientRect->left) {
    1443                 dprintf(("Adjusting cx from %d to %d", cx, (clientRect->right - clientRect->left) - x));
    1444                 cx = (clientRect->right - clientRect->left) - x;
    1445             }
    1446             if(y+cy > clientRect->bottom - clientRect->top) {
    1447                 dprintf(("Adjusting cy from %d to %d", cy, (clientRect->bottom - clientRect->top) - y));
    1448                 cy = (clientRect->bottom - clientRect->top) - y;
    1449             }
    1450 #endif
    1451 #if 0
    1452             //Correct coordinates if parent is a frame window (border adjustment)
    1453             //TODO: Not quite right (Solitaire child window placement slightly wrong)
    1454             if (window->isFrameWindow() && !(fuFlags & SWP_NOMOVE)) {
    1455                 if (HAS_DLGFRAME(window->getStyle(), window->getExStyle() ))
    1456                 {
    1457                     x += GetSystemMetrics(SM_CXDLGFRAME);
    1458                     y -= GetSystemMetrics(SM_CYDLGFRAME);
    1459                 }
    1460                 else
    1461                 {
    1462                     if (HAS_THICKFRAME(window->getStyle()))
    1463                     {
    1464                         x += GetSystemMetrics(SM_CXFRAME);
    1465                         y -= GetSystemMetrics(SM_CYFRAME);
    1466                     }
    1467                     else
    1468                     if (window->getStyle() & WS_BORDER)
    1469                     {
    1470                         x += GetSystemMetrics(SM_CXBORDER);
    1471                         y -= GetSystemMetrics(SM_CYBORDER);
    1472                     }
    1473                 }
    1474             }
    1475 #endif
    1476         }
    1477         else {
    1478             dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter));
    1479             hwndInsertAfter = 0;
    1480         }
    1481 
    1482         break;
    1483 
    1484     }
    1485     setstate = SWPOS_MOVE | SWPOS_SIZE | SWPOS_ACTIVATE | SWPOS_ZORDER;
    1486     if(fuFlags & SWP_DRAWFRAME)
    1487         setstate |= 0; //TODO
    1488     if(fuFlags & SWP_FRAMECHANGED)
    1489         setstate |= 0; //TODO
    1490     if(fuFlags & SWP_HIDEWINDOW)
    1491         setstate &= ~SWPOS_ZORDER;
    1492     if(fuFlags & SWP_NOACTIVATE)
    1493         setstate &= ~SWPOS_ACTIVATE;
    1494     if(fuFlags & SWP_NOCOPYBITS)
    1495         setstate |= 0;      //TODO
    1496     if(fuFlags & SWP_NOMOVE)
    1497         setstate &= ~SWPOS_MOVE;
    1498     if(fuFlags & SWP_NOSIZE)
    1499         setstate &= ~SWPOS_SIZE;
    1500     if(fuFlags & SWP_NOREDRAW)
    1501         setstate |= SWPOS_NOREDRAW;
    1502     if(fuFlags & SWP_NOZORDER)
    1503         setstate &= ~SWPOS_ZORDER;
    1504     if(fuFlags & SWP_SHOWWINDOW)
    1505         setstate |= SWPOS_SHOW;
    1506 
    1507     //TODO send NCCREATE if size changed or SWP_FRAMECHANGED flag specified.
    1508     return OSLibWinSetWindowPos(OS2HwndFrame, hwndInsertAfter, x, y, cx, cy, setstate);
     1469   BOOL rc = FALSE;
     1470   Win32Window *window;
     1471
     1472   dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
     1473
     1474   /* Validate the flags passed in ...                   */
     1475   if ( fuFlags &
     1476        ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     |
     1477          SWP_NOREDRAW   | SWP_NOACTIVATE | SWP_FRAMECHANGED |
     1478          SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   |
     1479          SWP_NOOWNERZORDER) )
     1480   {
     1481      return FALSE;
     1482   }
     1483
     1484   WINDOWPOS wpos;
     1485   SWP swp, swpOld;
     1486   ULONG parentHeight;
     1487
     1488   //****************************
     1489   // Set up with Windows values.
     1490   //****************************
     1491   wpos.flags            = fuFlags;
     1492   wpos.cy               = cy;
     1493   wpos.cx               = cx;
     1494   wpos.x                = x;
     1495   wpos.y                = y;
     1496   wpos.hwndInsertAfter  = hwndInsertAfter;
     1497   wpos.hwnd             = getWindowHandle();
     1498
     1499   //**********************************************
     1500   // Convert from Windows to PM coords and flags.
     1501   //**********************************************
     1502   if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE)) {
     1503       OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
     1504       parentHeight = isChild() ?
     1505           OSLibGetWindowHeight(getParent()->getOS2WindowHandle())
     1506         : OSLibQueryScreenHeight();
     1507   }
     1508   OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, parentHeight);
     1509
     1510   /* MapSWP can clear the SWP_MOVE and SWP_SIZE flags if the window is not
     1511    * being moved or sized.  If these were the only operations to be done
     1512    * and they have been cleared, return now.
     1513    */
     1514   if (swp.fl == 0)
     1515      return TRUE;
     1516
     1517   //*********************************************************************
     1518   //On Windows, a WM_GETMINMAXINFO is made to the app from within this API.
     1519   //We'll send a WM_QUERYTRACKINFO which is translated into a WM_GETMINMAXINFO
     1520   //and passed on to the app. Compare the values returned with the SWP cx and
     1521   //cy values.  They cannot be bigger than the max nor smaller than the min.
     1522   //*********************************************************************
     1523
     1524   if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
     1525   {
     1526      Win32Window *wndBehind = Win32Window::GetWindowFromHandle(swp.hwndInsertBehind);
     1527      swp.hwndInsertBehind   = wndBehind->getOS2WindowHandle();
     1528   }
     1529   if (isFrameWindow())
     1530   {
     1531      POINT maxSize, maxPos, minTrack, maxTrack;
     1532
     1533      GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
     1534
     1535      if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
     1536      if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
     1537      if (swp.cx < minTrack.x) swp.cx = minTrack.x;
     1538      if (swp.cy < minTrack.y) swp.cy = minTrack.y;
     1539      swp.hwnd = OS2HwndFrame;
     1540   } else
     1541      swp.hwnd = OS2Hwnd;
     1542   dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
     1543
     1544   //*****************************************************************************
     1545   // Squibble the window.  (WinSetMultWindowPos is faster than WinSetWindowPos.)
     1546   //*****************************************************************************
     1547   rc = OSLibWinSetMultWindowPos(&swp, 1);
     1548
     1549   if (rc == FALSE)
     1550   {
     1551//      SET_ERROR_LAST();
     1552   }
     1553   else
     1554   {
     1555      /* To implement support for SWP_FRAMECHANGED_W correctly, we would need
     1556      ** to send a WM_NCCALCSIZE message. This means DAX would have to support
     1557      ** the WM_NCCALCSIZE message. I don't think DAX can support this
     1558      ** message because it is tightly bound with the architecture of
     1559      ** overlapped windows (the "just one window" architecture). However,
     1560      ** we *can* support the SWP_FRAMECHANGED flag by sending the window
     1561      ** a WM_UPDATEFRAME, which will provide the behavior of WM_NCCALCSIZE.
     1562      */
     1563//      if (fuFlags & SWP_FRAMECHANGED_W)
     1564//         WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0);
     1565   }
     1566
     1567   return (rc);
    15091568}
    15101569//******************************************************************************
     
    15221581    return getParent()->getWindowHandle();
    15231582  }
    1524   else  return 0;
     1583  else  return 0;
    15251584}
    15261585//******************************************************************************
     
    15321591
    15331592   if(getParent()) {
    1534         oldhwnd = getParent()->getWindowHandle();
     1593        oldhwnd = getParent()->getWindowHandle();
    15351594   }
    15361595   else oldhwnd = 0;
     
    15381597   if(hwndNewParent == 0) {//desktop window = parent
    15391598    setParent(NULL);
    1540         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    1541         return oldhwnd;
     1599        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     1600        return oldhwnd;
    15421601   }
    15431602   newparent = GetWindowFromHandle(hwndNewParent);
    15441603   if(newparent)
    15451604   {
    1546         setParent(newparent);
    1547         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    1548         return oldhwnd;
     1605        setParent(newparent);
     1606        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     1607        return oldhwnd;
    15491608   }
    15501609   SetLastError(ERROR_INVALID_PARAMETER);
     
    15581617    return getParent()->getWindowHandle() == hwndParent;
    15591618  }
    1560   else  return 0;
     1619  else  return 0;
    15611620}
    15621621//******************************************************************************
     
    15771636    if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
    15781637    {//update region not empty
    1579         SendInternalMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0);
     1638        SendInternalMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0);
    15801639    }
    15811640    return TRUE;
     
    15931652{
    15941653 Win32Window  *win32wnd;
    1595  ULONG         magic;
    1596  ULONG         getcmd = 0;
    1597  HWND          hwndRelated;
     1654 ULONG         magic;
     1655 ULONG         getcmd = 0;
     1656 HWND          hwndRelated;
    15981657
    15991658    dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
    16001659    switch(uCmd)
    16011660    {
    1602         case GW_CHILD:
    1603             getcmd = QWOS_TOP;
    1604             break;
    1605         case GW_HWNDFIRST:
    1606             if(getParent()) {
    1607                     getcmd = QWOS_TOP; //top of child windows
    1608             }
    1609             else    getcmd = QWOS_TOP; //TODO
    1610             break;
    1611         case GW_HWNDLAST:
    1612             if(getParent()) {
    1613                     getcmd = QWOS_BOTTOM; //bottom of child windows
    1614             }
    1615             else    getcmd = QWOS_BOTTOM; //TODO
    1616             break;
    1617         case GW_HWNDNEXT:
    1618             getcmd = QWOS_NEXT;
    1619             break;
    1620         case GW_HWNDPREV:
    1621             getcmd = QWOS_PREV;
    1622             break;
    1623         case GW_OWNER:
    1624             if(owner) {
    1625                     return owner->getWindowHandle();
    1626             }
    1627             else    return 0;
     1661        case GW_CHILD:
     1662            getcmd = QWOS_TOP;
     1663            break;
     1664        case GW_HWNDFIRST:
     1665            if(getParent()) {
     1666                    getcmd = QWOS_TOP; //top of child windows
     1667            }
     1668            else    getcmd = QWOS_TOP; //TODO
     1669            break;
     1670        case GW_HWNDLAST:
     1671            if(getParent()) {
     1672                    getcmd = QWOS_BOTTOM; //bottom of child windows
     1673            }
     1674            else    getcmd = QWOS_BOTTOM; //TODO
     1675            break;
     1676        case GW_HWNDNEXT:
     1677            getcmd = QWOS_NEXT;
     1678            break;
     1679        case GW_HWNDPREV:
     1680            getcmd = QWOS_PREV;
     1681            break;
     1682        case GW_OWNER:
     1683            if(owner) {
     1684                    return owner->getWindowHandle();
     1685            }
     1686            else    return 0;
    16281687    }
    16291688    hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd);
    16301689    if(hwndRelated)
    16311690    {
    1632         win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
    1633         magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
    1634         if(CheckMagicDword(magic) && win32wnd)
    1635         {
    1636             return win32wnd->getWindowHandle();
    1637         }
     1691        win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
     1692        magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
     1693        if(CheckMagicDword(magic) && win32wnd)
     1694        {
     1695            return win32wnd->getWindowHandle();
     1696        }
    16381697    }
    16391698    return 0;
     
    16621721HWND Win32Window::GetActiveWindow()
    16631722{
    1664  HWND          hwndActive;
     1723 HWND          hwndActive;
    16651724 Win32Window  *win32wnd;
    1666  ULONG         magic;
     1725 ULONG         magic;
    16671726
    16681727  hwndActive = OSLibWinQueryActiveWindow();
     
    17251784
    17261785   switch(index) {
    1727         case GWL_EXSTYLE:
    1728                 oldval = dwExStyle;
    1729                 dwExStyle = value;
    1730                 return oldval;
    1731         case GWL_STYLE:
    1732                 oldval = dwStyle;
    1733                 dwStyle = value;
    1734                 return oldval;
    1735         case GWL_WNDPROC:
    1736                 oldval = (LONG)getWindowProc();
    1737                 setWindowProc((WNDPROC)value);
    1738                 return oldval;
    1739         case GWL_HINSTANCE:
    1740                 oldval = hInstance;
    1741                 hInstance = value;
    1742                 return oldval;
    1743         case GWL_HWNDPARENT:
    1744         return SetParent((HWND)value);
    1745 
    1746         case GWL_ID:
    1747                 oldval = getWindowId();
    1748                 setWindowId(value);
    1749                 return oldval;
    1750         case GWL_USERDATA:
    1751                 oldval = userData;
    1752                 userData = value;
    1753                 return oldval;
    1754         default:
    1755                 if(index >= 0 && index/4 < nrUserWindowLong)
    1756                 {
    1757                         oldval = userWindowLong[index/4];
    1758                         userWindowLong[index/4] = value;
    1759                         return oldval;
    1760                 }
    1761                 SetLastError(ERROR_INVALID_PARAMETER);
    1762                 return 0;
     1786        case GWL_EXSTYLE:
     1787                oldval = dwExStyle;
     1788                dwExStyle = value;
     1789                return oldval;
     1790        case GWL_STYLE:
     1791                oldval = dwStyle;
     1792                dwStyle = value;
     1793                return oldval;
     1794        case GWL_WNDPROC:
     1795                oldval = (LONG)getWindowProc();
     1796                setWindowProc((WNDPROC)value);
     1797                return oldval;
     1798        case GWL_HINSTANCE:
     1799                oldval = hInstance;
     1800                hInstance = value;
     1801                return oldval;
     1802        case GWL_HWNDPARENT:
     1803        return SetParent((HWND)value);
     1804
     1805        case GWL_ID:
     1806                oldval = getWindowId();
     1807                setWindowId(value);
     1808                return oldval;
     1809        case GWL_USERDATA:
     1810                oldval = userData;
     1811                userData = value;
     1812                return oldval;
     1813        default:
     1814                if(index >= 0 && index/4 < nrUserWindowLong)
     1815                {
     1816                        oldval = userWindowLong[index/4];
     1817                        userWindowLong[index/4] = value;
     1818                        return oldval;
     1819                }
     1820                SetLastError(ERROR_INVALID_PARAMETER);
     1821                return 0;
    17631822   }
    17641823}
     
    17681827{
    17691828   switch(index) {
    1770         case GWL_EXSTYLE:
    1771                 return dwExStyle;
    1772         case GWL_STYLE:
    1773                 return dwStyle;
    1774         case GWL_WNDPROC:
    1775                 return (ULONG)getWindowProc();
    1776         case GWL_HINSTANCE:
    1777                 return hInstance;
    1778         case GWL_HWNDPARENT:
    1779                 if(getParent()) {
    1780                         return getParent()->getWindowHandle();
    1781                 }
    1782                 else    return 0;
    1783         case GWL_ID:
    1784                 return getWindowId();
    1785         case GWL_USERDATA:
    1786                 return userData;
    1787         default:
    1788                 if(index >= 0 && index/4 < nrUserWindowLong)
    1789                 {
    1790                         return userWindowLong[index/4];
    1791                 }
    1792                 SetLastError(ERROR_INVALID_PARAMETER);
    1793                 return 0;
     1829        case GWL_EXSTYLE:
     1830                return dwExStyle;
     1831        case GWL_STYLE:
     1832                return dwStyle;
     1833        case GWL_WNDPROC:
     1834                return (ULONG)getWindowProc();
     1835        case GWL_HINSTANCE:
     1836                return hInstance;
     1837        case GWL_HWNDPARENT:
     1838                if(getParent()) {
     1839                        return getParent()->getWindowHandle();
     1840                }
     1841                else    return 0;
     1842        case GWL_ID:
     1843                return getWindowId();
     1844        case GWL_USERDATA:
     1845                return userData;
     1846        default:
     1847                if(index >= 0 && index/4 < nrUserWindowLong)
     1848                {
     1849                        return userWindowLong[index/4];
     1850                }
     1851                SetLastError(ERROR_INVALID_PARAMETER);
     1852                return 0;
    17941853   }
    17951854}
     
    18021861   if(index >= 0 && index/4 < nrUserWindowLong)
    18031862   {
    1804         oldval = ((WORD *)userWindowLong)[index/2];
    1805         ((WORD *)userWindowLong)[index/2] = value;
    1806         return oldval;
     1863        oldval = ((WORD *)userWindowLong)[index/2];
     1864        ((WORD *)userWindowLong)[index/2] = value;
     1865        return oldval;
    18071866   }
    18081867   SetLastError(ERROR_INVALID_PARAMETER);
     
    18151874   if(index >= 0 && index/4 < nrUserWindowLong)
    18161875   {
    1817         return ((WORD *)userWindowLong)[index/2];
     1876        return ((WORD *)userWindowLong)[index/2];
    18181877   }
    18191878   SetLastError(ERROR_INVALID_PARAMETER);
     
    18401899{
    18411900 Win32Window *win32wnd;
    1842  DWORD        magic;
     1901 DWORD        magic;
    18431902
    18441903  win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
  • trunk/src/user32/new/win32wnd.h

    r650 r693  
    1 /* $Id: win32wnd.h,v 1.24 1999-08-23 15:34:47 dengert Exp $ */
     1/* $Id: win32wnd.h,v 1.25 1999-08-25 15:08:51 dengert Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    2323class Win32Window;
    2424
    25 #define OFFSET_WIN32WNDPTR      0
    26 #define OFFSET_WIN32PM_MAGIC    4
    27 
    28 #define WIN32PM_MAGIC           0x12345678
    29 #define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
     25#define OFFSET_WIN32WNDPTR      0
     26#define OFFSET_WIN32PM_MAGIC    4
     27
     28#define WIN32PM_MAGIC           0x12345678
     29#define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
    3030
    3131typedef struct {
    32         USHORT          cb;
    33         Win32Window    *win32wnd;
    34         ULONG           win32CreateStruct;      //or dialog create dword
     32        USHORT          cb;
     33        Win32Window    *win32wnd;
     34        ULONG           win32CreateStruct;      //or dialog create dword
    3535} CUSTOMWNDDATA;
    3636
    3737typedef struct
    3838{
    39         ULONG           Msg;
    40         ULONG           wParam;
    41         ULONG           lParam;
     39        ULONG           Msg;
     40        ULONG           wParam;
     41        ULONG           lParam;
    4242} POSTMSG_PACKET;
    4343
    44 #define WM_WIN32_POSTMESSAGEA   0x4000
    45 #define WM_WIN32_POSTMESSAGEW   0x4001
    46 
    47 #define MAX_WINDOW_NAMELENGTH   256
     44#define WM_WIN32_POSTMESSAGEA   0x4000
     45#define WM_WIN32_POSTMESSAGEW   0x4001
     46
     47#define MAX_WINDOW_NAMELENGTH   256
    4848
    4949class Win32Window : private GenericObject, private ChildWindow
    5050{
    5151public:
    52         DWORD   magic;
    53 
    54                 Win32Window(DWORD objType);
    55                 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
     52        DWORD   magic;
     53
     54                Win32Window(DWORD objType);
     55                Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
    5656virtual        ~Win32Window();
    5757
    58 virtual  ULONG  MsgCreate(HWND hwndOS2, ULONG initParam);
    59          ULONG  MsgQuit();
    60          ULONG  MsgClose();
    61          ULONG  MsgDestroy();
    62          ULONG  MsgEnable(BOOL fEnable);
    63          ULONG  MsgShow(BOOL fShow);
    64          ULONG  MsgMove(ULONG x, ULONG y);
    65          ULONG  MsgHitTest(ULONG x, ULONG y);
    66          ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
    67          ULONG  MsgActivate(BOOL fActivate, HWND hwnd);
    68          ULONG  MsgSetFocus(HWND hwnd);
    69          ULONG  MsgKillFocus(HWND hwnd);
    70          ULONG  MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
    71          ULONG  MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
    72          ULONG  MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
    73          ULONG  MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
    74          ULONG  MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
    75          ULONG  MsgPaint(ULONG tmp1, ULONG tmp2);
    76          ULONG  MsgEraseBackGround(HDC hdc);
    77          ULONG  MsgSetText(LPSTR lpsz, LONG cch);
    78          ULONG  MsgGetTextLength();
    79          char  *MsgGetText();
    80 
    81 virtual  LONG   SetWindowLongA(int index, ULONG value);
    82 virtual  ULONG  GetWindowLongA(int index);
    83 virtual  WORD   SetWindowWord(int index, WORD value);
    84 virtual  WORD   GetWindowWord(int index);
    85 
    86          DWORD  getStyle()                      { return dwStyle; };
    87          DWORD  getExStyle()                    { return dwExStyle; };
    88          HWND   getWindowHandle()               { return Win32Hwnd; };
    89          HWND   getOS2WindowHandle()            { return OS2Hwnd; };
    90          HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
    91          BOOL   isFrameWindow()                 { return OS2Hwnd != OS2HwndFrame; };
    92    Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
    93          void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
    94        WNDPROC  getWindowProc()                 { return win32wndproc; };
    95          void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
    96         DWORD   getWindowId()                   { return windowId; };
    97          void   setWindowId(DWORD id)           { windowId = id; };
    98          ULONG  getWindowHeight()               { return rectClient.bottom - rectClient.top; };
    99          BOOL   isChild();
    100          PRECT  getClientRect()                 { return &rectClient; };
    101          PRECT  getWindowRect()                 { return &rectWindow; };
    102 
    103          DWORD  getFlags()                      { return flags; };
    104          void   setFlags(DWORD newflags)        { flags = newflags; };
    105 
    106          HACCEL GetAccelTable()                     { return (HACCEL) acceltableResource; };
    107          BOOL   SetAccelTable(ULONG hAccel);
    108 
    109          HMENU  GetMenu()                           { return (HMENU) menuResource; };
    110          BOOL   SetMenu(ULONG hMenu);
    111 
    112          BOOL   SetIcon(HICON hIcon);
    113          HICON  GetIcon()                           { return (HICON) iconResource; };
    114 
    115          BOOL   ShowWindow(ULONG nCmdShow);
    116          BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
    117          BOOL   DestroyWindow();
    118          HWND   SetActiveWindow();
    119          HWND   GetParent();
    120          HWND   SetParent(HWND hwndNewParent);
    121          BOOL   IsChild(HWND hwndParent);
    122          HWND   GetTopWindow();
    123          BOOL   UpdateWindow();
    124          BOOL   IsIconic();
    125          HWND   GetWindow(UINT uCmd);
    126          BOOL   EnableWindow(BOOL fEnable);
    127          BOOL   CloseWindow();
    128   static HWND   GetActiveWindow();
    129          BOOL   IsWindow();
    130          BOOL   IsWindowEnabled();
    131          BOOL   IsWindowVisible();
    132          BOOL   IsUnicode()  { return isUnicode; };
    133 
    134          BOOL   GetWindowRect(PRECT pRect);
    135          int    GetWindowTextLengthA();
    136          int    GetWindowTextA(LPSTR lpsz, int cch);
    137          BOOL   SetWindowTextA(LPCSTR lpsz);
    138 
    139        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    140        LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    141        BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    142        BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    143        LRESULT  DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
    144        LRESULT  DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
    145 
    146          void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
     58virtual  ULONG  MsgCreate(HWND hwndOS2, ULONG initParam);
     59         ULONG  MsgQuit();
     60         ULONG  MsgClose();
     61         ULONG  MsgDestroy();
     62         ULONG  MsgEnable(BOOL fEnable);
     63         ULONG  MsgShow(BOOL fShow);
     64         ULONG  MsgPosChanging(LPARAM lp);
     65         ULONG  MsgPosChanged(LPARAM lp);
     66         ULONG  MsgMove(ULONG x, ULONG y);
     67         ULONG  MsgHitTest(ULONG x, ULONG y);
     68         ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
     69         ULONG  MsgActivate(BOOL fActivate, HWND hwnd);
     70         ULONG  MsgSetFocus(HWND hwnd);
     71         ULONG  MsgKillFocus(HWND hwnd);
     72         ULONG  MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
     73         ULONG  MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
     74         ULONG  MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
     75         ULONG  MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
     76         ULONG  MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
     77         ULONG  MsgPaint(ULONG tmp1, ULONG tmp2);
     78         ULONG  MsgEraseBackGround(HDC hdc);
     79         ULONG  MsgSetText(LPSTR lpsz, LONG cch);
     80         ULONG  MsgGetTextLength();
     81         char  *MsgGetText();
     82
     83virtual  LONG   SetWindowLongA(int index, ULONG value);
     84virtual  ULONG  GetWindowLongA(int index);
     85virtual  WORD   SetWindowWord(int index, WORD value);
     86virtual  WORD   GetWindowWord(int index);
     87
     88         DWORD  getStyle()                      { return dwStyle; };
     89         DWORD  getExStyle()                    { return dwExStyle; };
     90         HWND   getWindowHandle()               { return Win32Hwnd; };
     91         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
     92         HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
     93         BOOL   isFrameWindow()                 { return OS2Hwnd != OS2HwndFrame; };
     94   Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
     95         void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
     96       WNDPROC  getWindowProc()                 { return win32wndproc; };
     97         void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
     98        DWORD   getWindowId()                   { return windowId; };
     99         void   setWindowId(DWORD id)           { windowId = id; };
     100         ULONG  getWindowHeight()               { return rectClient.bottom - rectClient.top; };
     101         BOOL   isChild();
     102         PRECT  getClientRect()                 { return &rectClient; };
     103         PRECT  getWindowRect()                 { return &rectWindow; };
     104
     105         DWORD  getFlags()                      { return flags; };
     106         void   setFlags(DWORD newflags)        { flags = newflags; };
     107
     108         HACCEL GetAccelTable()                     { return (HACCEL) acceltableResource; };
     109         BOOL   SetAccelTable(ULONG hAccel);
     110
     111         HMENU  GetMenu()                           { return (HMENU) menuResource; };
     112         BOOL   SetMenu(ULONG hMenu);
     113
     114         BOOL   SetIcon(HICON hIcon);
     115         HICON  GetIcon()                           { return (HICON) iconResource; };
     116
     117         BOOL   ShowWindow(ULONG nCmdShow);
     118         BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
     119         BOOL   DestroyWindow();
     120         HWND   SetActiveWindow();
     121         HWND   GetParent();
     122         HWND   SetParent(HWND hwndNewParent);
     123         BOOL   IsChild(HWND hwndParent);
     124         HWND   GetTopWindow();
     125         BOOL   UpdateWindow();
     126         BOOL   IsIconic();
     127         HWND   GetWindow(UINT uCmd);
     128         BOOL   EnableWindow(BOOL fEnable);
     129         BOOL   CloseWindow();
     130  static HWND   GetActiveWindow();
     131         BOOL   IsWindow();
     132         BOOL   IsWindowEnabled();
     133         BOOL   IsWindowVisible();
     134         BOOL   IsUnicode()  { return isUnicode; };
     135
     136         BOOL   GetWindowRect(PRECT pRect);
     137         int    GetWindowTextLengthA();
     138         int    GetWindowTextA(LPSTR lpsz, int cch);
     139         BOOL   SetWindowTextA(LPCSTR lpsz);
     140
     141       LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     142       LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     143       BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     144       BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     145       LRESULT  DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
     146       LRESULT  DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
     147
     148         void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
    147149
    148150Win32WndClass  *getClass()  { return windowClass; };
    149151
    150 static  HWND  Win32ToOS2Handle(HWND hwnd)
     152static  HWND  Win32ToOS2Handle(HWND hwnd)
    151153{
    152154 Win32Window *window = GetWindowFromHandle(hwnd);
    153155
    154156  if(window) {
    155         return window->getOS2WindowHandle();
     157        return window->getOS2WindowHandle();
    156158  }
    157   else  return hwnd;    //OS/2 window handle
     159  else  return hwnd;    //OS/2 window handle
    158160}
    159161
    160 static  HWND  OS2ToWin32Handle(HWND hwnd)
     162static  HWND  OS2ToWin32Handle(HWND hwnd)
    161163{
    162164 Win32Window *window = GetWindowFromOS2Handle(hwnd);
    163165
    164166  if(window) {
    165         return window->getWindowHandle();
     167        return window->getWindowHandle();
    166168  }
    167   else  return hwnd;    //OS/2 window handle
     169  else  return hwnd;    //OS/2 window handle
    168170}
    169171
     
    172174
    173175protected:
    174        LRESULT  SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    175        LRESULT  SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    176         void    Init();
    177 
    178         HWND    OS2Hwnd;
    179         HWND    OS2HwndFrame;
    180         HWND    OS2HwndMenu;
    181         HWND    Win32Hwnd;
    182         BOOL    isUnicode;
    183 
    184         int     posx, posy, width, height;
    185 
    186         // values normally contained in the standard window words
    187         ULONG   dwExStyle;              //GWL_EXSTYLE
    188         ULONG   dwStyle;                //GWL_STYLE
    189       WNDPROC   win32wndproc;           //GWL_WNDPROC
    190         ULONG   hInstance;              //GWL_HINSTANCE
     176       LRESULT  SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     177       LRESULT  SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     178        void    Init();
     179
     180        HWND    OS2Hwnd;
     181        HWND    OS2HwndFrame;
     182        HWND    OS2HwndMenu;
     183        HWND    Win32Hwnd;
     184        BOOL    isUnicode;
     185
     186        int     posx, posy, width, height;
     187
     188        // values normally contained in the standard window words
     189        ULONG   dwExStyle;              //GWL_EXSTYLE
     190        ULONG   dwStyle;                //GWL_STYLE
     191      WNDPROC   win32wndproc;           //GWL_WNDPROC
     192        ULONG   hInstance;              //GWL_HINSTANCE
    191193//Moved in ChildWindow class
    192 /////   Win32Window *parent;                    //GWL_HWNDPARENT
    193         ULONG   windowId;               //GWL_ID
    194         ULONG   userData;               //GWL_USERDATA
    195 
    196          HWND   hwndLinkAfter;
    197         DWORD   flags;
    198         DWORD   lastHitTestVal;         //Last value returned by WM_NCHITTEST handler
    199 
    200         BOOL    isIcon;
    201         BOOL    fCreated;
    202         BOOL    fFirstShow;
     194/////   Win32Window *parent;                    //GWL_HWNDPARENT
     195        ULONG   windowId;               //GWL_ID
     196        ULONG   userData;               //GWL_USERDATA
     197
     198         HWND   hwndLinkAfter;
     199        DWORD   flags;
     200        DWORD   lastHitTestVal;         //Last value returned by WM_NCHITTEST handler
     201
     202        BOOL    isIcon;
     203        BOOL    fCreated;
     204        BOOL    fFirstShow;
    203205
    204206   Win32Window *owner;
     
    208210 Win32Resource *iconResource;
    209211
    210         char    windowNameA[MAX_WINDOW_NAMELENGTH];
    211         WCHAR   windowNameW[MAX_WINDOW_NAMELENGTH];
    212         ULONG   wndNameLength;
    213 
    214         ULONG  *userWindowLong;
    215         ULONG   nrUserWindowLong;
    216 
    217         RECT    rectWindow;
    218         RECT    rectClient;
     212        char    windowNameA[MAX_WINDOW_NAMELENGTH];
     213        WCHAR   windowNameW[MAX_WINDOW_NAMELENGTH];
     214        ULONG   wndNameLength;
     215
     216        ULONG  *userWindowLong;
     217        ULONG   nrUserWindowLong;
     218
     219        RECT    rectWindow;
     220        RECT    rectClient;
    219221
    220222Win32WndClass  *windowClass;
     
    224226private:
    225227#ifndef OS2_INCLUDED
    226         BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
    227 
    228         void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
    229 
    230         LONG  SendNCCalcSize(BOOL calcValidRect,
    231                              RECT *newWindowRect, RECT *oldWindowRect,
    232                              RECT *oldClientRect, WINDOWPOS *winpos,
    233                              RECT *newClientRect );
     228        BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
     229
     230        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
     231
     232        LONG  SendNCCalcSize(BOOL calcValidRect,
     233                             RECT *newWindowRect, RECT *oldWindowRect,
     234                             RECT *oldClientRect, WINDOWPOS *winpos,
     235                             RECT *newClientRect );
    234236
    235237     LRESULT  SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
    236238     {
    237         if(isUnicode)
    238                 return SendInternalMessageW(msg, wParam, lParam);
    239         else    return SendInternalMessageA(msg, wParam, lParam);
     239        if(isUnicode)
     240                return SendInternalMessageW(msg, wParam, lParam);
     241        else    return SendInternalMessageA(msg, wParam, lParam);
    240242     }
    241243#endif
     
    243245
    244246
    245 #define BUTTON_LEFTDOWN         0
    246 #define BUTTON_LEFTUP           1
    247 #define BUTTON_LEFTDBLCLICK     2
    248 #define BUTTON_RIGHTUP          3
    249 #define BUTTON_RIGHTDOWN        4
    250 #define BUTTON_RIGHTDBLCLICK    5
    251 #define BUTTON_MIDDLEUP         6
    252 #define BUTTON_MIDDLEDOWN       7
    253 #define BUTTON_MIDDLEDBLCLICK   8
    254 
    255 #define WMMOVE_LBUTTON          1
    256 #define WMMOVE_MBUTTON          2
    257 #define WMMOVE_RBUTTON          4
    258 #define WMMOVE_CTRL             8
    259 #define WMMOVE_SHIFT            16
    260 
    261 
    262 #define CMD_MENU                1
    263 #define CMD_CONTROL             2
    264 #define CMD_ACCELERATOR         3
    265 
    266 #define WIN32SC_SIZE         0xf000
    267 #define WIN32SC_MOVE         0xf010
     247#define BUTTON_LEFTDOWN         0
     248#define BUTTON_LEFTUP           1
     249#define BUTTON_LEFTDBLCLICK     2
     250#define BUTTON_RIGHTUP          3
     251#define BUTTON_RIGHTDOWN        4
     252#define BUTTON_RIGHTDBLCLICK    5
     253#define BUTTON_MIDDLEUP         6
     254#define BUTTON_MIDDLEDOWN       7
     255#define BUTTON_MIDDLEDBLCLICK   8
     256
     257#define WMMOVE_LBUTTON          1
     258#define WMMOVE_MBUTTON          2
     259#define WMMOVE_RBUTTON          4
     260#define WMMOVE_CTRL             8
     261#define WMMOVE_SHIFT            16
     262
     263
     264#define CMD_MENU                1
     265#define CMD_CONTROL             2
     266#define CMD_ACCELERATOR         3
     267
     268#define WIN32SC_SIZE         0xf000
     269#define WIN32SC_MOVE         0xf010
    268270#define WIN32SC_MINIMIZE     0xf020
    269271#define WIN32SC_MAXIMIZE     0xf030
    270272#define WIN32SC_NEXTWINDOW   0xf040
    271273#define WIN32SC_PREVWINDOW   0xf050
    272 #define WIN32SC_CLOSE        0xf060
     274#define WIN32SC_CLOSE        0xf060
    273275#define WIN32SC_VSCROLL      0xf070
    274276#define WIN32SC_HSCROLL      0xf080
     
    279281#define WIN32SC_TASKLIST     0xf130
    280282#define WIN32SC_SCREENSAVE   0xf140
    281 #define WIN32SC_HOTKEY       0xf150
    282 
    283 #define KEY_ALTDOWN             1
    284 #define KEY_PREVDOWN            2
    285 #define KEY_UP                  4
    286 #define KEY_DEADKEY             8
     283#define WIN32SC_HOTKEY       0xf150
     284
     285#define KEY_ALTDOWN             1
     286#define KEY_PREVDOWN            2
     287#define KEY_UP                  4
     288#define KEY_DEADKEY             8
    287289
    288290#endif //__cplusplus
Note: See TracChangeset for help on using the changeset viewer.