]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/window.cpp
more MS-DOS stuff in generic wxFileDialog
[wxWidgets.git] / src / os2 / window.cpp
index 70e3b0958e5aeb6981ea452808b4b79023b12503..f6e3e6082ef48df6cb32745b6823fbad90207431 100644 (file)
@@ -147,6 +147,9 @@ static void TranslateKbdEventToMouse( wxWindow* pWin
 //
 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
+
+static wxWindow*                    gpWinBeingCreated = NULL;
+
 // ---------------------------------------------------------------------------
 // event tables
 // ---------------------------------------------------------------------------
@@ -366,7 +369,6 @@ bool wxWindowOS2::Create(
 )
 {
     HWND                            hParent = NULLHANDLE;
-    wxPoint                         vPos = rPos; // The OS/2 position
     ULONG                           ulCreateFlags = 0;
     WXDWORD                         dwExStyle = 0;
 
@@ -388,37 +390,12 @@ bool wxWindowOS2::Create(
 
         pParent->AddChild(this);
         hParent = GetWinHwnd(pParent);
-        //
-        // OS2 uses normal coordinates, no bassackwards Windows ones
-        //
-        if (pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
-            pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
-           )
-        {
-            wxWindow*               pGrandParent = NULL;
 
-            pGrandParent = pParent->GetParent();
-            if (pGrandParent)
-                nTempy = pGrandParent->GetSize().y - (vPos.y + rSize.y);
-            else
-                nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
-        }
-        else
-            nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
-        vPos.y = nTempy;
         if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
              pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
            )
             ulCreateFlags |= WS_CLIPSIBLINGS;
     }
-    else
-    {
-        RECTL                   vRect;
-
-        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
-        hParent = HWND_DESKTOP;
-        vPos.y = vRect.yTop - (vPos.y + rSize.y);
-    }
 
     //
     // Most wxSTYLES are really PM Class specific styles and will be
@@ -464,23 +441,17 @@ bool wxWindowOS2::Create(
     }
 
     //
-    // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
-    // and no presentation parameters
+    // Generic OS/2 Windows have no Control Data but other classes
+    // that call OS2Create may have some.
     //
-    OS2Create( hParent
-              ,(PSZ)wxCanvasClassName
+    OS2Create( (PSZ)wxCanvasClassName
               ,rName.c_str()
               ,ulCreateFlags
-              ,vPos.x
-              ,vPos.y
-              ,WidthDefault(rSize.x)
-              ,HeightDefault(rSize.y)
-              ,NULLHANDLE
-              ,NULLHANDLE
-              ,m_windowId
-              ,NULL
-              ,NULL
+              ,rPos
+              ,rSize
+              ,NULL         // Control Data
               ,dwExStyle
+              ,TRUE         // Child
              );
 
     return(TRUE);
@@ -614,10 +585,72 @@ bool wxWindowOS2::SetFont(
 
     if (hWnd != 0)
     {
-        wxChar                      zFont[128];
+        char                        zFont[128];
+        char                        zFacename[30];
+        char                        zWeight[30];
+        char                        zStyle[30];
+
+        //
+        // The fonts available for Presentation Params are just three
+        // outline fonts, the rest are available to the GPI, so we must
+        // map the families to one of these three
+        //
+        switch(rFont.GetFamily())
+        {
+            case wxSCRIPT:
+            case wxDECORATIVE:
+            case wxROMAN:
+                strcpy(zFacename,"Times New Roman");
+                break;
+
+            case wxTELETYPE:
+            case wxMODERN:
+                strcpy(zFacename, "Courier");
+                break;
+
+            case wxSWISS:
+            case wxDEFAULT:
+            default:
+                strcpy(zFacename, "Helvetica");
+                break;
+        }
+
+        switch(rFont.GetWeight())
+        {
+            default:
+            case wxNORMAL:
+            case wxLIGHT:
+                zWeight[0] = '\0';
+                break;
+
+            case wxBOLD:
+            case wxFONTWEIGHT_MAX:
+                strcpy(zWeight, "Bold");
+                break;
+        }
+        switch(rFont.GetStyle())
+        {
+            case wxITALIC:
+            case wxSLANT:
+                strcpy(zStyle, "Italic");
+                break;
 
-        sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
-        return (bool)::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont);
+            default:
+                zStyle[0] = '\0';
+                break;
+        }
+        sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
+        if (zWeight[0] != '\0')
+        {
+            strcat(zFont, " ");
+            strcat(zFont, zWeight);
+        }
+        if (zStyle[0] != '\0')
+        {
+            strcat(zFont, " ");
+            strcat(zFont, zStyle);
+        }
+        ::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
     }
     return(TRUE);
 }
@@ -1044,6 +1077,19 @@ void wxWindowOS2::UnsubclassWin()
     }
 } // end of wxWindowOS2::UnsubclassWin
 
+bool wxCheckWindowWndProc(
+  WXHWND                            hWnd
+, WXFARPROC                         fnWndProc
+)
+{
+    static char                     zBuffer[512];
+    CLASSINFO                       vCls;
+
+    ::WinQueryClassName((HWND)hWnd, (LONG)512, (PCH)zBuffer);
+    ::WinQueryClassInfo(wxGetInstance(), (PSZ)zBuffer, &vCls);
+    return(fnWndProc == (WXFARPROC)vCls.pfnWindowProc);
+} // end of WinGuiBase_CheckWindowWndProc
+
 //
 // Make a Windows extended style from the given wxWindows window style
 //
@@ -1268,6 +1314,27 @@ void wxWindowOS2::Clear()
     vDc.Clear();
 } // end of wxWindowOS2::Clear
 
+void wxWindowOS2::Update()
+{
+    ::WinUpdateWindow(GetHwnd());
+} // end of wxWindowOS2::Update
+
+void wxWindowOS2::Freeze()
+{
+   ::WinSendMsg(GetHwnd(), WM_VRNDISABLED, (MPARAM)0, (MPARAM)0);
+} // end of wxWindowOS2::Freeze
+
+void wxWindowOS2::Thaw()
+{
+   ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0);
+
+    //
+    // We need to refresh everything or otherwise he invalidated area is not
+    // repainted.
+    //
+    Refresh();
+} // end of wxWindowOS2::Thaw
+
 void wxWindowOS2::Refresh(
   bool                              bEraseBack
 , const wxRect*                     pRect
@@ -1355,9 +1422,17 @@ void wxWindowOS2::DoGetSize(
 , int*                              pHeight
 ) const
 {
-    HWND                            hWnd = GetHwnd();
+    HWND                            hWnd;
     RECTL                           vRect;
 
+    if (IsKindOf(CLASSINFO(wxFrame)))
+    {
+        wxFrame*                    pFrame = wxDynamicCast(this, wxFrame);
+        hWnd = pFrame->GetFrame();
+    }
+    else
+        hWnd = GetHwnd();
+
     ::WinQueryWindowRect(hWnd, &vRect);
 
     if (pWidth)
@@ -1373,49 +1448,36 @@ void wxWindowOS2::DoGetPosition(
 ) const
 {
     HWND                            hWnd = GetHwnd();
-    RECT                            vRect;
+    SWP                             vSwp;
     POINTL                          vPoint;
+    wxWindow*                       pParent = GetParent();
 
-    ::WinQueryWindowRect(hWnd, &vRect);
+    //
+    // It would seem that WinQueryWindowRect would be the correlary to
+    // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
+    // origin position in screen coordinates, WinQueryWindowRect returns it
+    // relative to itself, i.e. (0,0).  To get the same under PM we must
+    // us WinQueryWindowPos.  This call, unlike the WIN32 call, however,
+    // returns a position relative to it's parent, so no parent adujstments
+    // are needed under OS/2.  Also, windows should be created using
+    // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already
+    // reflect that.
+    //
+    ::WinQueryWindowPos(hWnd, &vSwp);
 
-    vPoint.x = vRect.xLeft;
-    vPoint.y = vRect.yBottom;
+    vPoint.x = vSwp.x;
+    vPoint.y = vSwp.y;
 
     //
-    // We do the adjustments with respect to the parent only for the "real"
-    // children, not for the dialogs/frames
+    // We may be faking the client origin. So a window that's really at (0,
+    // 30) may appear (to wxWin apps) to be at (0, 0).
     //
-    if (!IsTopLevel())
+    if (pParent)
     {
-        HWND                        hParentWnd = 0;
-        wxWindow*                   pParent = GetParent();
-
-        if (pParent)
-            hParentWnd = GetWinHwnd(pParent);
-
-        //
-        // Since we now have the absolute screen coords, if there's a parent we
-        // must subtract its bottom left corner
-        //
-        if (hParentWnd)
-        {
-            RECTL                   vRect2;
-
-            ::WinQueryWindowRect(hParentWnd, &vRect2);
-            vPoint.x -= vRect.xLeft;
-            vPoint.y -= vRect.yBottom;
-        }
-
-        //
-        // We may be faking the client origin. So a window that's really at (0,
-        // 30) may appear (to wxWin apps) to be at (0, 0).
-        //
-        if (pParent) {
-            wxPoint                     vPt(pParent->GetClientAreaOrigin());
+        wxPoint                     vPt(pParent->GetClientAreaOrigin());
 
-            vPoint.x -= vPt.x;
-            vPoint.y -= vPt.y;
-        }
+        vPoint.x -= vPt.x;
+        vPoint.y -= vPt.y;
     }
 
     if (pX)
@@ -1430,18 +1492,14 @@ void wxWindowOS2::DoScreenToClient(
 ) const
 {
     HWND                            hWnd = GetHwnd();
-    POINTL                          ptl;
-
-    ptl.x = pX ? *pX : 0;
-    ptl.y = pY ? *pY : 0;
+    SWP                             vSwp;
 
-    ::WinMapWindowPoints(HWND_DESKTOP, hWnd, &ptl, 1);
+    ::WinQueryWindowPos(hWnd, &vSwp);
 
     if (pX)
-        *pX = ptl.x;
+        *pX += vSwp.x;
     if (pY)
-        *pY = ptl.y;
-
+        *pY += vSwp.y;
 } // end of wxWindowOS2::DoScreenToClient
 
 void wxWindowOS2::DoClientToScreen(
@@ -1450,17 +1508,14 @@ void wxWindowOS2::DoClientToScreen(
 ) const
 {
     HWND                            hWnd = GetHwnd();
-    POINTL                          ptl;
-
-    ptl.x = pX ? *pX : 0;
-    ptl.y = pY ? *pY : 0;
+    SWP                             vSwp;
 
-    ::WinMapWindowPoints(hWnd, HWND_DESKTOP, &ptl, 1);
+    ::WinQueryWindowPos(hWnd, &vSwp);
 
     if (pX)
-        *pX = ptl.x;
+        *pX += vSwp.x;
     if (pY)
-        *pY = ptl.y;
+        *pY += vSwp.y;
 } // end of wxWindowOS2::DoClientToScreen
 
 //
@@ -1473,18 +1528,9 @@ void wxWindowOS2::DoGetClientSize(
 ) const
 {
     HWND                            hWnd = GetHwnd();
-    HWND                            hWndClient;
     RECTL                           vRect;
 
-    if (IsKindOf(CLASSINFO(wxFrame)))
-        hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
-    else
-        hWndClient = NULLHANDLE;
-    if( hWndClient == NULLHANDLE)
-       ::WinQueryWindowRect(GetHwnd(), &vRect);
-    else
-       ::WinQueryWindowRect(hWndClient, &vRect);
-
+   ::WinQueryWindowRect(hWnd, &vRect);
     if (pWidth)
         *pWidth  = vRect.xRight;
     if (pHeight)
@@ -1498,29 +1544,31 @@ void wxWindowOS2::DoMoveWindow(
 , int                               nHeight
 )
 {
-#if 0 // x and y coords should already be in os2 coordinates
     RECTL                           vRect;
     HWND                            hParent;
     wxWindow*                       pParent = GetParent();
 
     if (pParent)
-        hParent = GetWinHwnd(pParent);
+    {
+        int                         nOS2Height = GetOS2ParentHeight(pParent);
+
+        nY = nOS2Height - (nY + nHeight);
+    }
     else
-        hParent = HWND_DESKTOP;
-    ::WinQueryWindowRect(hParent, &vRect);
-    nY = vRect.yTop - (nY + nHeight);
-#endif
-    if ( !::WinSetWindowPos( GetHwnd()
-                            ,HWND_TOP
-                            ,(LONG)nX
-                            ,(LONG)nY
-                            ,(LONG)nWidth
-                            ,(LONG)nHeight
-                            ,SWP_SIZE | SWP_MOVE
-                           ))
     {
-        wxLogLastError("MoveWindow");
+        RECTL                       vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
     }
+    ::WinSetWindowPos( GetHwnd()
+                      ,HWND_TOP
+                      ,(LONG)nX
+                      ,(LONG)nY
+                      ,(LONG)nWidth
+                      ,(LONG)nHeight
+                      ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+                     );
 } // end of wxWindowOS2::DoMoveWindow
 
 //
@@ -1553,8 +1601,29 @@ void wxWindowOS2::DoSetSize(
     GetPosition(&nCurrentX, &nCurrentY);
     GetSize(&nCurrentWidth, &nCurrentHeight);
 
+    //
     // ... and don't do anything (avoiding flicker) if it's already ok
-    if (nX == nCurrentX && nY == nCurrentY &&
+    //
+    //
+    // Must convert Y coords to test for equality under OS/2
+    //
+    int                             nY2 = nY;
+    wxWindow*                       pParent = (wxWindow*)GetParent();
+
+    if (pParent)
+    {
+        int                         nOS2Height = GetOS2ParentHeight(pParent);
+
+        nY2 = nOS2Height - (nY2 + nHeight);
+    }
+    else
+    {
+        RECTL                       vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY2 = vRect.yTop - (nY2 + nHeight);
+    }
+    if (nX == nCurrentX && nY2 == nCurrentY &&
         nWidth == nCurrentWidth && nHeight == nCurrentHeight)
     {
         return;
@@ -1614,79 +1683,28 @@ void wxWindowOS2::DoSetClientSize(
 {
     wxWindow*                       pParent = GetParent();
     HWND                            hWnd = GetHwnd();
-#if 0
     HWND                            hParentWnd = (HWND)0;
-    HWND                            hClientWnd = (HWND)0;
+    POINTL                          vPoint;
     RECTL                           vRect;
-    RECT                            vRect2;
-    RECT                            vRect3;
+    RECTL                           vRect2;
+    RECTL                           vRect3;
+    HWND                            hClientWnd = (HWND)0;
 
-    hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+    hClientWnd = ::WinWindowFromID(hWnd, FID_CLIENT);
     ::WinQueryWindowRect(hClientWnd, &vRect2);
-
-    if (pParent)
-        hParentWnd = (HWND) pParent->GetHWND();
-
     ::WinQueryWindowRect(hWnd, &vRect);
     ::WinQueryWindowRect(hParentWnd, &vRect3);
-    //
-    // Find the difference between the entire window (title bar and all)
-    // and the client area; add this to the new client size to move the
-    // window. OS/2 is backward from windows on height
-    //
+
     int                             nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
     int                             nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
 
-    //
-    // If there's a parent, must subtract the parent's bottom left corner
-    // since MoveWindow moves relative to the parent
-    //
-    POINTL                          vPoint;
-
     vPoint.x = vRect2.xLeft;
     vPoint.y = vRect2.yBottom;
     if (pParent)
-    {             x
+    {
         vPoint.x -= vRect3.xLeft;
         vPoint.y -= vRect3.yBottom;
     }
-#else
-    HWND                            hParentWnd = (HWND)0;
-    HWND                            hClientWnd = (HWND)0;
-    RECTL                           vRect;
-    RECT                            vRect2;
-
-    hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
-    ::WinQueryWindowRect(hClientWnd, &vRect2);
-    ::WinQueryWindowRect(hWnd, &vRect2);
-
-    if (pParent)
-        hParentWnd = (HWND) pParent->GetHWND();
-
-    ::WinQueryWindowRect(hWnd, &vRect);
-    //
-    // Find the difference between the entire window (title bar and all)
-    // and the client area; add this to the new client size to move the
-    // window. OS/2 is backward from windows on height
-    //
-    int nActualWidth  = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
-    int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
-
-    nActualWidth  = nWidth;
-    nActualHeight = nHeight;
-    //
-    // If there's a parent, must subtract the parent's bottom left corner
-    // since MoveWindow moves relative to the parent
-    //
-    POINTL                          vPoint;
-
-    vPoint.x = vRect2.xLeft;
-    vPoint.y = vRect2.yBottom;
-    if (pParent)
-    {
-        ::WinMapWindowPoints(hWnd, hParentWnd, &vPoint, 1);
-    }
-#endif
 
     DoMoveWindow(vPoint.x, vPoint.y, nActualWidth, nActualHeight);
 
@@ -1745,55 +1763,114 @@ void wxWindowOS2::GetTextExtent(
 , const wxFont*                     pTheFont
 ) const
 {
-    const wxFont*                   pFontToUse = pTheFont;
-    HPS                             hPs;
-
-    hPs = ::WinGetPS(GetHwnd());
+    POINTL                          avPoint[TXTBOX_COUNT];
+    POINTL                          vPtMin;
+    POINTL                          vPtMax;
+    int                             i;
+    int                             l;
+    FONTMETRICS                     vFM; // metrics structure
+    BOOL                            bRc;
+    char*                           pStr;
+    ERRORID                         vErrorCode; // last error id code
+    HPS                             hPS;
 
-    // Just prevent compiler warnings
-    wxString dummy = rString;
-    pX = pX;
-    pY = pY;
-    pDescent = pDescent;
-    pExternalLeading = pExternalLeading;
-/*
-// TODO: Will have to play with fonts later
 
-    if (!pFontToUse)
-        pFontToUse = &m_font;
+    hPS = ::WinGetPS(GetHwnd());
 
-    HFONT                           hFnt = 0;
-    HFONT                           hFfontOld = 0;
+    l = rString.Length();
+    if (l > 0L)
+    {
+        pStr = (PCH)rString.c_str();
 
-    if (pFontToUse && pFontToUse->Ok())
+        //
+        // In world coordinates.
+        //
+        bRc = ::GpiQueryTextBox( hPS
+                                ,l
+                                ,pStr
+                                ,TXTBOX_COUNT // return maximum information
+                                ,avPoint      // array of coordinates points
+                               );
+        if (bRc)
+        {
+            vPtMin.x = avPoint[0].x;
+            vPtMax.x = avPoint[0].x;
+            vPtMin.y = avPoint[0].y;
+            vPtMax.y = avPoint[0].y;
+            for (i = 1; i < 4; i++)
+            {
+                if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
+                if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
+                if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
+                if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
+            }
+            bRc = ::GpiQueryFontMetrics( hPS
+                                        ,sizeof(FONTMETRICS)
+                                        ,&vFM
+                                       );
+            if (!bRc)
+            {
+                vPtMin.x = 0;
+                vPtMin.y = 0;
+                vPtMax.x = 0;
+                vPtMax.y = 0;
+            }
+        }
+        else
+        {
+            vPtMin.x = 0;
+            vPtMin.y = 0;
+            vPtMax.x = 0;
+            vPtMax.y = 0;
+        }
+    }
+    else
     {
-        ::GpiCreateLog
-        hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
-        if (hFnt)
-            hFontOld = (HFONT)SelectObject(dc,fnt);
+        vPtMin.x = 0;
+        vPtMin.y = 0;
+        vPtMax.x = 0;
+        vPtMax.y = 0;
     }
+    if (pX)
+        *pX = (vPtMax.x - vPtMin.x + 1);
+    if (pY)
+        *pY = (vPtMax.y - vPtMin.y + 1);
+    if (pDescent)
+    {
+        if (bRc)
+            *pDescent = vFM.lMaxDescender;
+        else
+            *pDescent = 0;
+    }
+    if (pExternalLeading)
+    {
+        if (bRc)
+            *pExternalLeading = vFM.lExternalLeading;
+        else
+            *pExternalLeading = 0;
+    }
+    ::WinReleasePS(hPS);
+} // end of wxWindow::GetTextExtent
 
-    SIZE sizeRect;
-    TEXTMETRIC tm;
-    GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
-    GetTextMetrics(dc, &tm);
-
-    if ( fontToUse && fnt && hfontOld )
-        SelectObject(dc, hfontOld);
-
-    ReleaseDC(hWnd, dc);
-
-    if ( x )
-        *x = sizeRect.cx;
-    if ( y )
-        *y = sizeRect.cy;
-    if ( descent )
-        *descent = tm.tmDescent;
-    if ( externalLeading )
-        *externalLeading = tm.tmExternalLeading;
-*/
-    ::WinReleasePS(hPs);
-}
+bool wxWindowOS2::IsMouseInWindow() const
+{
+    //
+    // Get the mouse position
+    POINTL                          vPt;
+
+    ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
+
+    //
+    // Find the window which currently has the cursor and go up the window
+    // chain until we find this window - or exhaust it
+    //
+    HWND                            hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
+
+    while (hWnd && (hWnd != GetHwnd()))
+        hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
+
+    return hWnd != NULL;
+} // end of wxWindowOS2::IsMouseInWindow
 
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
 // ---------------------------------------------------------------------------
@@ -2448,7 +2525,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
                 if (uKeyFlags & KC_KEYUP)
                 {
                     //TODO: check if the cast to WXWORD isn't causing trouble
-                    bProcessed = HandleKeyUp((WXWORD)wParam, lParam);
+                    bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
                     break;
                 }
                 else // keydown event
@@ -2458,7 +2535,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
                     // return 0 now (we've handled it). DON't RETURN
                     // we still need to process further
                     //
-                    HandleKeyDown((WXWORD)wParam, lParam);
+                    HandleKeyDown((WXDWORD)wParam, lParam);
                     if (uKeyFlags & KC_VIRTUALKEY)
                     {
                         USHORT          uVk = SHORT2FROMMP((MPARAM)lParam);
@@ -2492,13 +2569,13 @@ MRESULT wxWindowOS2::OS2WindowProc(
                             case VK_DOWN:
                             case VK_UP:
                             default:
-                                bProcessed = HandleChar((WXWORD)wParam, lParam);
+                                bProcessed = HandleChar((WXDWORD)wParam, lParam);
                          }
                          break;
                     }
                     else // WM_CHAR -- Always an ASCII character
                     {
-                        bProcessed = HandleChar((WXWORD)wParam, lParam, TRUE);
+                        bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
                         break;
                     }
                 }
@@ -2526,6 +2603,48 @@ MRESULT wxWindowOS2::OS2WindowProc(
             }
             break;
 
+        case WM_CONTROL:
+            switch(SHORT2FROMMP(wParam))
+            {
+                case SPBN_UPARROW:
+                case SPBN_DOWNARROW:
+                case SPBN_CHANGE:
+                    {
+                        char        zVal[10];
+                        long        lVal;
+
+                        ::WinSendMsg( HWNDFROMMP(lParam)
+                                     ,SPBM_QUERYVALUE
+                                     ,&zVal
+                                     ,MPFROM2SHORT( (USHORT)10
+                                                   ,(USHORT)SPBQ_UPDATEIFVALID
+                                                  )
+                                    );
+                        lVal = atol(zVal);
+                        bProcessed = OS2OnScroll( wxVERTICAL
+                                                 ,(int)SHORT2FROMMP(wParam)
+                                                 ,(int)lVal
+                                                 ,HWNDFROMMP(lParam)
+                                                );
+                    }
+                    break;
+
+                case SLN_SLIDERTRACK:
+                    {
+                        HWND                hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
+                        wxWindowOS2*        pChild = wxFindWinFromHandle(hWnd);
+
+                        if (pChild->IsKindOf(CLASSINFO(wxSlider)))
+                            bProcessed = OS2OnScroll( wxVERTICAL
+                                                     ,(int)SHORT2FROMMP(wParam)
+                                                     ,(int)LONGFROMMP(lParam)
+                                                     ,hWnd
+                                                    );
+                    }
+                    break;
+            }
+            break;
+
 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
         case WM_CTLCOLORCHANGE:
             {
@@ -2542,20 +2661,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
             mResult = (MRESULT)(FALSE);
             break;
 
-        //
-        // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
-        // things such as colors and fonts and such
-        //
-        case WM_QUERYWINDOWPARAMS:
-            {
-                PWNDPARAMS          pWndParams = (PWNDPARAMS)wParam;
-
-                bProcessed = HandleWindowParams( pWndParams
-                                                ,lParam
-                                               );
-            }
-            break;
-
             // the return value for this message is ignored
         case WM_SYSCOLORCHANGE:
             bProcessed = HandleSysColorChange();
@@ -2565,11 +2670,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
             bProcessed = HandlePaletteChanged();
             break;
 
-        case WM_PRESPARAMCHANGED:
-            bProcessed = HandlePresParamChanged(wParam);
-            break;
-
-
         // move all drag and drops to wxDrg
         case WM_ENDDRAG:
             bProcessed = HandleEndDrag(wParam);
@@ -2745,149 +2845,175 @@ void wxWindowOS2::OS2DetachWindowMenu()
 #endif // __WXUNIVERSAL__
 } // end of wxWindowOS2::OS2DetachWindowMenu
 
+bool wxWindowOS2::OS2GetCreateWindowCoords(
+  const wxPoint&                    rPos
+, const wxSize&                     rSize
+, int&                              rnX
+, int&                              rnY
+, int&                              rnWidth
+, int&                              rnHeight
+) const
+{
+    bool                            bNonDefault = FALSE;
+
+    if (rPos.x == -1)
+    {
+        //
+        // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
+        // just as well set it to CW_USEDEFAULT as well
+        rnX = rnY = CW_USEDEFAULT;
+    }
+    else
+    {
+        rnX = rPos.x;
+        rnY = rPos.y == -1 ? CW_USEDEFAULT : rPos.y;
+        bNonDefault = TRUE;
+    }
+    if (rSize.x == -1)
+    {
+        //
+        // As abobe, h is not used at all in this case anyhow
+        //
+        rnWidth = rnHeight = CW_USEDEFAULT;
+    }
+    else
+    {
+        rnWidth  = rSize.x;
+        rnHeight = rSize.y == -1 ? CW_USEDEFAULT : rSize.y;
+        bNonDefault = TRUE;
+    }
+    return bNonDefault;
+} // end of wxWindowOS2::OS2GetCreateWindowCoords
+
 bool wxWindowOS2::OS2Create(
-  WXHWND                            hParent
-, PSZ                               zClass
-, const wxChar*                     zTitle
+  PSZ                               zClass
+, const char*                       zTitle
 , WXDWORD                           dwStyle
-, long                              lX
-, long                              lY
-, long                              lWidth
-, long                              lHeight
-, WXHWND                            hOwner
-, WXHWND                            WXUNUSED(hZOrder)
-, unsigned long                     ulId
+, const wxPoint&                    rPos
+, const wxSize&                     rSize
 , void*                             pCtlData
-, void*                             pPresParams
 , WXDWORD                           dwExStyle
+, bool                              bIsChild
 )
 {
     ERRORID                         vError;
     wxString                        sError;
-    long                            lX1      = 0L;
-    long                            lY1      = 0L;
-    long                            lWidth1  = 20L;
-    long                            lHeight1 = 20L;
-    int                             nControlId = 0;
-    int                             nNeedsubclass = 0;
-    PCSZ                            pszClass = zClass;
-
-    //
-    // Find parent's size, if it exists, to set up a possible default
-    // panel size the size of the parent window
-    //
-    lX1 = lX;
-    lY1 = lY;
-    if (lWidth > -1L)
-        lWidth1 = lWidth;
-    if (lHeight > -1L)
-        lHeight1 = lHeight;
-
-    wxWndHook = this;
+    int                             nX      = 0L;
+    int                             nY      = 0L;
+    int                             nWidth  = 0L;
+    int                             nHeight = 0L;
+    wxWindow*                       pParent = GetParent();
+    HWND                            hWnd = NULLHANDLE;
+    HWND                            hParent;
+    long                            lControlId = 0L;
+    wxWindowCreationHook            vHook(this);
+    wxString                        sClassName((wxChar*)zClass);
+
+    OS2GetCreateWindowCoords( rPos
+                             ,rSize
+                             ,nX
+                             ,nY
+                             ,nWidth
+                             ,nHeight
+                            );
 
-    //
-    // check to see if the new window is a standard control
-    //
-    if ((ULONG)zClass == (ULONG)WC_BUTTON ||
-        (ULONG)zClass == (ULONG)WC_COMBOBOX ||
-        (ULONG)zClass == (ULONG)WC_CONTAINER ||
-        (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
-        (ULONG)zClass == (ULONG)WC_FRAME ||
-        (ULONG)zClass == (ULONG)WC_LISTBOX ||
-        (ULONG)zClass == (ULONG)WC_MENU ||
-        (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
-        (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
-        (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
-        (ULONG)zClass == (ULONG)WC_STATIC ||
-        (ULONG)zClass == (ULONG)WC_TITLEBAR ||
-        (ULONG)zClass == (ULONG)WC_VALUESET
-       )
-    {
-            nControlId = ulId;
-    }
+    if (GetWindowStyleFlag() & wxPOPUP_WINDOW)
+        hParent = HWND_DESKTOP;
     else
     {
-        // no standard controls
-        if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
+        if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent )
         {
-            pszClass =  WC_FRAME;
-            nNeedsubclass = 1;
+            //
+            // This is either a normal child window or a top level window with
+            // wxFRAME_TOOL_WINDOW style (see below)
+            //
+            hParent = GetHwndOf(pParent);
         }
         else
         {
-            nControlId = ulId;
-            if(nControlId < 0)
-                nControlId = FID_CLIENT;
+            //
+            // This is either a window for which no parent was specified (not
+            // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
+            // style: we should use NULL parent HWND for it or it would be
+            // always on top of its parent which is not what we usually want
+            // (in fact, we only want it for frames with the special
+            // wxFRAME_TOOL_WINDOW as above)
+            //
+            hParent = NULL;
+        }
+    }
+    if (bIsChild)
+    {
+        lControlId = GetId();
+        if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
+        {
+            dwStyle |= WS_CLIPSIBLINGS;
         }
     }
-
-   HWND parent;
-   if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
-   {
-       // popup windows should have desktop as parent because they shouldn't
-       // be limited to the parents client area as child windows usually are
-       parent = HWND_DESKTOP;
-   }
-   else if ( hParent )
-   {
-       parent = hParent;
-   }
-   else
-   {
-       // top level window
-       parent = NULL;
-   }
-
     //
-    // We will either have a registered class via string name or a standard PM Class via a long
+    // For each class "Foo" we have we also have "FooNR" ("no repaint") class
+    // which is the same but without CS_[HV]REDRAW class styles so using it
+    // ensures that the window is not fully repainted on each resize
     //
-    m_hWnd = (WXHWND)::WinCreateWindow(parent, zClass,
-                                       (PSZ)zTitle ? zTitle : wxT(""),
-                                       dwStyle, lX1, lY1, lWidth, lHeight,
-                                       hOwner, HWND_TOP, (ULONG)nControlId,
-                                       pCtlData, pPresParams);
-
-    if (!m_hWnd)
+    if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE)
     {
-        vError = ::WinGetLastError(vHabmain);
-        sError = wxPMErrorToStr(vError);
-        wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
-        return FALSE;
+        sClassName += wxT("NR");
     }
-    m_dwExStyle = dwExStyle;
-    ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
-    wxWndHook = NULL;
-
-#ifdef __WXDEBUG__
-    wxNode*                         pNode = wxWinHandleList->Member(this);
 
-    if (pNode)
+    //
+    // If the window being created is a Frame's Statusbar we need to use
+    // the actual Frame's size, not its client
+    //
+    if (pParent)
     {
-        HWND                        hWnd = (HWND)pNode->GetKeyInteger();
-
-        if (hWnd != (HWND)m_hWnd)
-
+        if (IsKindOf(CLASSINFO(wxStatusBar)) &&
+            pParent->IsKindOf(CLASSINFO(wxFrame)))
         {
-            wxLogError("A second HWND association is being added for the same window!");
+            RECTL                   vRect;
+            wxFrame*                pFrame = wxDynamicCast(pParent, wxFrame);
+
+            ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+            nY = vRect.yTop - (nY + nHeight);
         }
+        else
+            nY = pParent->GetSize().y - (nY + nHeight);
     }
-#endif
-    wxAssociateWinWithHandle((HWND)m_hWnd
-                             ,this
-                            );
-    //
-    // Now need to subclass window.
-    //
-    if(!nNeedsubclass)
+    else
     {
-         wxAssociateWinWithHandle((HWND)m_hWnd,this);
+        RECTL                   vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
     }
-    else
+    m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
+                                      ,(PSZ)sClassName.c_str()
+                                      ,(PSZ)zTitle ? zTitle : ""
+                                      ,(ULONG)dwStyle
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,NULLHANDLE
+                                      ,HWND_TOP
+                                      ,(ULONG)lControlId
+                                      ,pCtlData
+                                      ,NULL
+                                     );
+    if (!m_hWnd)
     {
-        SubclassWin(GetHWND());
+        vError = ::WinGetLastError(wxGetInstance());
+        sError = wxPMErrorToStr(vError);
+        return FALSE;
     }
+    SubclassWin(m_hWnd);
+    SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+    SetSize( nX
+            ,nY
+            ,nWidth
+            ,nHeight
+           );
     return TRUE;
-} // end of wxWindowOS2::OS2Create
+} // end of WinGuiBase_Window::OS2Create
 
 // ===========================================================================
 // OS2 PM message handlers
@@ -3282,14 +3408,6 @@ bool wxWindowOS2::HandleCtlColor(
     return TRUE;
 } // end of wxWindowOS2::HandleCtlColor
 
-bool wxWindowOS2::HandleWindowParams(
-  PWNDPARAMS                        WXUNUSED(pWndParams)
-, WXLPARAM                          WXUNUSED(lParam)
-)
-{
-// TODO: I'll do something here, just not sure what yet
-    return TRUE;
-}
 
 // Define for each class of dialog and control
 WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC),
@@ -3315,21 +3433,6 @@ bool wxWindowOS2::HandlePaletteChanged()
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxWindowOS2::HandlePaletteChanged
 
-bool wxWindowOS2::HandlePresParamChanged(
-  WXWPARAM                          WXUNUSED(wParam)
-)
-{
-    //
-    // TODO:  Once again I'll do something here when I need it
-    //
-    //wxQueryNewPaletteEvent event(GetId());
-    //event.SetEventObject(this);
-    // if the background is erased
-//            bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
-
-    return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
-}
-
 //
 // Responds to colour changes: passes event on to children.
 //
@@ -3385,65 +3488,6 @@ bool wxWindowOS2::HandlePaint()
     vEvent.SetEventObject(this);
     bProcessed = GetEventHandler()->ProcessEvent(vEvent);
 
-    if (!bProcessed)
-    {
-        HPS                         hPS;
-
-        hPS = ::WinBeginPaint( GetHwnd()
-                              ,NULLHANDLE
-                              ,&vRect
-                             );
-        if(hPS)
-        {
-#if 0
-            ::GpiCreateLogColorTable( hPS
-                                     ,0L
-                                     ,LCOLF_CONSECRGB
-                                     ,0L
-                                     ,(LONG)wxTheColourDatabase->m_nSize
-                                     ,(PLONG)wxTheColourDatabase->m_palTable
-                                    );
-#endif
-            ::GpiCreateLogColorTable( hPS
-                                     ,0L
-                                     ,LCOLF_RGB
-                                     ,0L
-                                     ,0L
-                                     ,NULL
-                                    );
-
-            ::WinFillRect(hPS, &vRect,  GetBackgroundColour().GetPixel());
-
-            if (m_dwExStyle)
-            {
-                LINEBUNDLE                      vLineBundle;
-
-                vLineBundle.lColor     = 0x00000000; // Black
-                vLineBundle.usMixMode  = FM_OVERPAINT;
-                vLineBundle.fxWidth    = 1;
-                vLineBundle.lGeomWidth = 1;
-                vLineBundle.usType     = LINETYPE_SOLID;
-                vLineBundle.usEnd      = 0;
-                vLineBundle.usJoin     = 0;
-                ::GpiSetAttrs( hPS
-                              ,PRIM_LINE
-                              ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE
-                              ,0L
-                              ,&vLineBundle
-                             );
-                ::WinQueryWindowRect(GetHwnd(), &vRect);
-                wxDrawBorder( hPS
-                             ,vRect
-                             ,m_dwExStyle
-                            );
-            }
-            ::WinEndPaint(hPS);
-        }
-    }
-
-    ::GpiDestroyRegion(hPS, hRgn);
-    ::WinReleasePS(hPS);
-
     return GetEventHandler()->ProcessEvent(vEvent); //bProcessed;
 } // end of wxWindowOS2::HandlePaint
 
@@ -3755,7 +3799,7 @@ wxKeyEvent wxWindowOS2::CreateKeyEvent(
 // WM_KEYDOWN one
 //
 bool wxWindowOS2::HandleChar(
-  WXWORD                            wParam
+  WXDWORD                           wParam
 , WXLPARAM                          lParam
 , bool                              isASCII
 )
@@ -3849,7 +3893,7 @@ bool wxWindowOS2::HandleKeyDown(
 } // end of wxWindowOS2::HandleKeyDown
 
 bool wxWindowOS2::HandleKeyUp(
-  WXWORD                            wParam
+  WXDWORD                           wParam
 , WXLPARAM                          lParam
 )
 {
@@ -3941,18 +3985,207 @@ bool wxWindowOS2::OS2OnScroll(
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxWindowOS2::OS2OnScroll
 
+void wxWindowOS2::MoveChildren(
+  int                               nDiff
+)
+{
+    SWP                                 vSwp;
+
+    for (wxWindowList::Node* pNode = GetChildren().GetFirst();
+         pNode;
+         pNode = pNode->GetNext())
+    {
+        wxWindow*                   pWin = pNode->GetData();
+
+        ::WinQueryWindowPos( GetHwndOf(pWin)
+                            ,&vSwp
+                           );
+        if (pWin->IsKindOf(CLASSINFO(wxControl)))
+        {
+            wxControl*          pCtrl;
+
+            //
+            // Must deal with controls that have margins like ENTRYFIELD.  The SWP
+            // struct of such a control will have and origin offset from its intended
+            // position by the width of the margins.
+            //
+            pCtrl = wxDynamicCast(pWin, wxControl);
+            vSwp.y -= pCtrl->GetYComp();
+            vSwp.x -= pCtrl->GetXComp();
+        }
+        ::WinSetWindowPos( GetHwndOf(pWin)
+                          ,HWND_TOP
+                          ,vSwp.x
+                          ,vSwp.y - nDiff
+                          ,vSwp.cx
+                          ,vSwp.cy
+                          ,SWP_MOVE
+                         );
+        if (pWin->IsKindOf(CLASSINFO(wxRadioBox)))
+        {
+            wxRadioBox*     pRadioBox;
+
+            pRadioBox = wxDynamicCast(pWin, wxRadioBox);
+            pRadioBox->AdjustButtons( (int)vSwp.x
+                                     ,(int)vSwp.y - nDiff
+                                     ,(int)vSwp.cx
+                                     ,(int)vSwp.cy
+                                     ,pRadioBox->GetSizeFlags()
+                                    );
+        }
+        if (pWin->IsKindOf(CLASSINFO(wxSlider)))
+        {
+            wxSlider*           pSlider;
+
+            pSlider = wxDynamicCast(pWin, wxSlider);
+            pSlider->AdjustSubControls( (int)vSwp.x
+                                       ,(int)vSwp.y - nDiff
+                                       ,(int)vSwp.cx
+                                       ,(int)vSwp.cy
+                                       ,(int)pSlider->GetSizeFlags()
+                                      );
+        }
+    }
+} // end of wxWindowOS2::MoveChildren
+
+//
+//  Getting the Y position for a window, like a control, is a real
+//  pain.  There are three sitatuions we must deal with in determining
+//  the OS2 to wxWindows Y coordinate.
+//
+//  1)  The controls are created in a dialog.
+//      This is the easiest since a dialog is created with its original
+//      size so the standard: Y = ParentHeight - (Y + ControlHeight);
+//
+//  2)  The controls are direct children of a frame
+//      In this instance the controls are actually children of the Frame's
+//      client.  During creation the frame's client resizes several times
+//      during creation of the status bar and toolbars.  The CFrame class
+//      will take care of this using its AlterChildPos proc.
+//
+//  3)  The controls are children of a panel, which in turn is a child of
+//      a frame.
+//      This is the nastiest case.  A panel is created as the only child of
+//      the frame and as such, when a frame has only one child, the child is
+//      expanded to fit the entire client area of the frame.  Because the
+//      controls are created BEFORE this occurs their positions are totally
+//      whacked and any call to WinQueryWindowPos will return invalid
+//      coordinates.  So for this situation we have to compare the size of
+//      the panel at control creation time with that of the frame client.  If
+//      they are the same we can use the standard Y position equation.  If
+//      not, then we must use the Frame Client's dimensions to position them
+//      as that will be the eventual size of the panel after the frame resizes
+//      it!
+//
+int wxWindowOS2::GetOS2ParentHeight(
+  wxWindowOS2*               pParent
+)
+{
+    wxWindowOS2*             pGrandParent = NULL;
+
+    //
+    // Case 1
+    //
+    if (pParent->IsKindOf(CLASSINFO(wxDialog)))
+        return(pParent->GetSize().y);
+
+    //
+    // Case 2 -- if we are one of the separately built standard Frame
+    //           children, like a statusbar, menubar, or toolbar we want to
+    //           use the frame, itself, for positioning.  Otherwise we are
+    //           child window and want to use the Frame's client.
+    //
+    else if (pParent->IsKindOf(CLASSINFO(wxFrame)))
+    {
+        if (IsKindOf(CLASSINFO(wxStatusBar)) ||
+            IsKindOf(CLASSINFO(wxMenuBar))   ||
+            IsKindOf(CLASSINFO(wxToolBar))
+           )
+            return(pParent->GetSize().y);
+        else
+            return(pParent->GetClientSize().y);
+    }
+
+    //
+    // Case 3 -- this is for any window that is the sole child of a Frame.
+    //           The grandparent must exist and it must be of type CFrame
+    //           and it's height must be different. Otherwise the standard
+    //           applies.
+    //
+    else
+    {
+        pGrandParent = pParent->GetParent();
+        if (pGrandParent &&
+            pGrandParent->IsKindOf(CLASSINFO(wxFrame)) &&
+            pGrandParent->GetClientSize().y != pParent->GetSize().y
+           )
+        {
+            int                     nParentHeight = 0L;
+            int                     nStatusBarHeight = 0L;
+            wxFrame*                pFrame = wxDynamicCast(pGrandParent, wxFrame);
+            wxStatusBar*            pStatbar = pFrame->GetStatusBar();
+
+            nParentHeight = pGrandParent->GetClientSize().y;
+            if (pStatbar)
+                nStatusBarHeight = pStatbar->GetSize().y;
+            nParentHeight -= nStatusBarHeight;
+            return(nParentHeight);
+        }
+        else
+            //
+            // Panel is a child of some other kind of window so we'll
+            // just use it's original size
+            //
+            return(pParent->GetClientSize().y);
+    }
+    return(0L);
+} // end of wxWindowOS2::GetOS2ParentHeight
+
+wxWindowCreationHook::wxWindowCreationHook(
+  wxWindow*                         pWinBeingCreated
+)
+{
+    gpWinBeingCreated = pWinBeingCreated;
+} // end of wxWindowCreationHook::wxWindowCreationHook
+
+wxWindowCreationHook::~wxWindowCreationHook()
+{
+    gpWinBeingCreated = NULL;
+} // end of wxWindowCreationHook::~wxWindowCreationHook
+
 // ===========================================================================
 // global functions
 // ===========================================================================
 
 void wxGetCharSize(
-  WXHWND                            WXUNUSED(hWnd)
-, int*                              WXUNUSED(pX)
-, int*                              WXUNUSED(pY)
+  WXHWND                            hWnd
+, int*                              pX
+, int*                              pY
 ,wxFont*                            WXUNUSED(pTheFont)
 )
 {
-  // TODO: we'll do this later
+    FONTMETRICS                     vFM;
+    HPS                             hPS;
+    BOOL                            rc;
+
+    hPS =::WinGetPS(hWnd);
+
+    rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM);
+    if (rc)
+    {
+        if (pX)
+            *pX = vFM.lAveCharWidth;
+        if (pY)
+            *pY = vFM.lEmHeight + vFM.lExternalLeading;
+    }
+    else
+    {
+        if (pX)
+            *pX = 10;
+        if (pY)
+            *pY = 15;
+    }
+    ::WinReleasePS(hPS);
 } // end of wxGetCharSize
 
 //