Index: trunk/src/user32/dc.cpp
===================================================================
--- trunk/src/user32/dc.cpp	(revision 1332)
+++ trunk/src/user32/dc.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: dc.cpp,v 1.13 1999-10-14 09:22:38 sandervl Exp $ */
+/* $Id: dc.cpp,v 1.14 1999-10-17 12:17:42 cbratschi Exp $ */
 
 /*
@@ -667,5 +667,6 @@
 //   {
 //      WinSendMsg( hwnd, /* WM_DRAW */ 0x20D, (MPARAM)hps, MPVOID );
-      selectClientArea(wnd, pHps, &rect);
+      //CB: subclassed window haven't got a frame
+      if (!wnd->isSubclassedOS2Wnd()) selectClientArea(wnd, pHps, &rect);
 //   }
 
Index: trunk/src/user32/listbox.cpp
===================================================================
--- trunk/src/user32/listbox.cpp	(revision 1332)
+++ trunk/src/user32/listbox.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: listbox.cpp,v 1.6 1999-10-14 18:27:55 sandervl Exp $ */
+/* $Id: listbox.cpp,v 1.7 1999-10-17 12:17:42 cbratschi Exp $ */
 /*
  * Listbox controls
@@ -24,6 +24,4 @@
  * - Unicode
  * - Locale handling
- CB:
-  - KillSystemTimer, SetSystemTimer
  */
 
@@ -201,5 +199,5 @@
     else
     {
-       	info.nPos  = descr->top_item;
+        info.nPos  = descr->top_item;
 
         info.nPage = LISTBOX_GetCurrentPageSize( hwnd, descr );
@@ -212,13 +210,13 @@
             info.fMask |= SIF_DISABLENOSCROLL;
 
-	if(info.nMax > (INT)info.nPage) {
-	    ShowScrollBar(hwnd, SB_VERT, TRUE);
-	    EnableScrollBar(hwnd, SB_VERT, ESB_ENABLE_BOTH);		
+        if(info.nMax > (INT)info.nPage) {
+            ShowScrollBar(hwnd, SB_VERT, TRUE);
+            EnableScrollBar(hwnd, SB_VERT, ESB_ENABLE_BOTH);
             SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
-	}
-	else {
-	    ShowScrollBar(hwnd, SB_VERT, FALSE);
-	    EnableScrollBar(hwnd, SB_VERT, ESB_DISABLE_BOTH);		
-	}
+        }
+        else {
+            ShowScrollBar(hwnd, SB_VERT, FALSE);
+            EnableScrollBar(hwnd, SB_VERT, ESB_DISABLE_BOTH);
+        }
 
         if (descr->horz_extent)
@@ -1902,8 +1900,7 @@
 static LRESULT LISTBOX_HandleLButtonUp( HWND hwnd, LB_DESCR *descr )
 {
-/* CB: implement!
     if (LISTBOX_Timer != LB_TIMER_NONE)
         KillSystemTimer( hwnd, LB_TIMER_ID );
-*/
+
     LISTBOX_Timer = LB_TIMER_NONE;
     if (descr->captured)
@@ -1963,7 +1960,6 @@
     if (!LISTBOX_HandleTimer( hwnd, descr, descr->focus_item, LISTBOX_Timer ))
     {
-/* CB: implement!
         KillSystemTimer( hwnd, LB_TIMER_ID );
-*/
+
         LISTBOX_Timer = LB_TIMER_NONE;
     }
@@ -2016,12 +2012,9 @@
     /* Start/stop the system timer */
 
-/* CB: implement!
     if (dir != LB_TIMER_NONE)
         SetSystemTimer( hwnd, LB_TIMER_ID, LB_SCROLL_TIMEOUT, NULL);
-*/
-/* CB: implement!
     else if (LISTBOX_Timer != LB_TIMER_NONE)
         KillSystemTimer( hwnd, LB_TIMER_ID );
-*/
+
     LISTBOX_Timer = dir;
 }
@@ -2566,5 +2559,5 @@
             LISTBOX_HandleMouseMove( hwnd, descr, (INT16)LOWORD(lParam),
                                      (INT16)HIWORD(lParam) );
-	return 1; //SvL: Bugfix -> PMWINDOW expects non-zero return value if
+        return 1; //SvL: Bugfix -> PMWINDOW expects non-zero return value if
                   //               we want to restore the default mouse cursor
 
@@ -2678,17 +2671,17 @@
 
                    GetClientRect(hwnd, &clientRect);
-		   if (PtInRect( &clientRect, mousePos ))
-		   {
-		       captured = descr->captured;
-		       descr->captured = TRUE;			
-		
-		       LISTBOX_HandleMouseMove( hwnd, descr,
-						    mousePos.x, mousePos.y);
+                   if (PtInRect( &clientRect, mousePos ))
+                   {
+                       captured = descr->captured;
+                       descr->captured = TRUE;
+
+                       LISTBOX_HandleMouseMove( hwnd, descr,
+                                                    mousePos.x, mousePos.y);
                        descr->captured = captured;
                    }
                    else
                    {
-		       LISTBOX_HandleMouseMove( hwnd, descr,
-		                		    mousePos.x, mousePos.y);
+                       LISTBOX_HandleMouseMove( hwnd, descr,
+                                                    mousePos.x, mousePos.y);
                    }
 
Index: trunk/src/user32/oslibwin.cpp
===================================================================
--- trunk/src/user32/oslibwin.cpp	(revision 1332)
+++ trunk/src/user32/oslibwin.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.29 1999-10-14 19:31:30 sandervl Exp $ */
+/* $Id: oslibwin.cpp,v 1.30 1999-10-17 12:17:43 cbratschi Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -73,6 +73,6 @@
 
         dwFrameStyle |= FCF_NOBYTEALIGN;
-        if (hwndParent == HWND_DESKTOP && dwFrameStyle & FCF_TITLEBAR) 
-           	dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
+        if (hwndParent == HWND_DESKTOP && dwFrameStyle & FCF_TITLEBAR)
+                dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
 
         dwWinStyle   &= ~WS_CLIPCHILDREN;
@@ -147,5 +147,5 @@
       *OSFrameStyle |= FCF_SIZEBORDER;
       *borderHeight = *borderWidth = 2;
-    } 
+    }
     else
     if(dwStyle & WS_BORDER_W)
@@ -160,5 +160,5 @@
     if(dwStyle & WS_HSCROLL_W)
           *OSFrameStyle |= FCF_HORZSCROLL;
-  } 
+  }
   else
   {
@@ -191,5 +191,5 @@
   //Clear certain frame bits when the window doesn't have a titlebar
   if(!(*OSFrameStyle & FCF_TITLEBAR)) {
-	*OSFrameStyle &= ~(FCF_MINBUTTON|FCF_MAXBUTTON|FCF_SYSMENU);
+        *OSFrameStyle &= ~(FCF_MINBUTTON|FCF_MAXBUTTON|FCF_SYSMENU);
   }
   return TRUE;
@@ -642,5 +642,5 @@
          }
       }
- 
+
       if (flags & SWP_SIZE)
       {
@@ -654,5 +654,5 @@
       }
       y  = parentHeight - y - cy;
-      
+
 
        if ((pswpOld->x == x) && (pswpOld->y == y))
@@ -678,5 +678,5 @@
 {
  BOOL rc;
- 
+
    WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
 
@@ -764,5 +764,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL OSLibWinShowScrollBar(HWND hwndParent, HWND hwndScroll, int scrollBar, 
+BOOL OSLibWinShowScrollBar(HWND hwndParent, HWND hwndScroll, int scrollBar,
                            BOOL fShow, BOOL fForceChange)
 {
@@ -956,2 +956,9 @@
 //******************************************************************************
 //******************************************************************************
+PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
+{
+  return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
+}
+//******************************************************************************
+//******************************************************************************
+
Index: trunk/src/user32/oslibwin.h
===================================================================
--- trunk/src/user32/oslibwin.h	(revision 1332)
+++ trunk/src/user32/oslibwin.h	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.16 1999-10-14 18:27:57 sandervl Exp $ */
+/* $Id: oslibwin.h,v 1.17 1999-10-17 12:17:43 cbratschi Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -38,5 +38,5 @@
 
 HWND  OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
-                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, 
+                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
                            HWND *hwndFrame, ULONG id);
 
@@ -273,3 +273,5 @@
 void  OSLibTranslateScrollCmdAndMsg(ULONG *msg, ULONG *scrollcmd);
 
+PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc);
+
 #endif //__OSLIBWIN_H__
Index: trunk/src/user32/pmframe.cpp
===================================================================
--- trunk/src/user32/pmframe.cpp	(revision 1332)
+++ trunk/src/user32/pmframe.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: pmframe.cpp,v 1.6 1999-10-14 21:37:44 sandervl Exp $ */
+/* $Id: pmframe.cpp,v 1.7 1999-10-17 12:17:44 cbratschi Exp $ */
 /*
  * Win32 Frame Managment Code for OS/2
@@ -183,17 +183,17 @@
 
       wndchild = Win32BaseWindow::GetWindowFromOS2FrameHandle(pswp->hwnd);
-      if(wndchild && wndchild->isChild()) 
+      if(wndchild && wndchild->isChild())
       {
 #if 0
        SWP swp = *pswp;
 
-  	MRESULT rc = OldFrameProc(hwnd, msg, mp1, mp2);
-	pswp->x = swp.x;
-	pswp->y = swp.y;
-	pswp->fl = swp.fl;
+        MRESULT rc = OldFrameProc(hwnd, msg, mp1, mp2);
+        pswp->x = swp.x;
+        pswp->y = swp.y;
+        pswp->fl = swp.fl;
 #endif
-      	dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
-      	RestoreOS2TIB();
-      	return (MRESULT)0;
+        dprintf(("PMFRAME: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
+        RestoreOS2TIB();
+        return (MRESULT)0;
       }
       goto RunDefFrameProc;
@@ -272,5 +272,5 @@
 
           GetSizeBox(win32wnd,&rect);
-          hps = WinGetPS(hwnd);
+          hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
           DrawSizeBox(hps,rect);
           WinReleasePS(hps);
@@ -289,8 +289,10 @@
         SetWin32TIB();
 
+        WinQueryWindowRect(hwnd,&rect);
+        rect.xRight = rect.xRight-rect.xLeft;
+        rect.yTop = rect.yTop-rect.yBottom;
+        rect.xLeft = rect.yBottom = 0;
         hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
-        WinQueryWindowRect(hwnd,&rect);
         DrawFrame(hps,&rect,win32wnd);
-        WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
         WinReleasePS(hps);
 
@@ -316,5 +318,5 @@
 
           GetSizeBox(win32wnd,&rect);
-          hps = WinGetPS(hwnd);
+          hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
           DrawSizeBox(hps,rect);
           WinReleasePS(hps);
@@ -323,21 +325,24 @@
           return res;
         } else goto RunDefFrameProc;
-      } 
-//SvL: I doubt this is necessary. Just look at winhlp32. First it draws the
-//     the background gray and then white.
-#if 0
-      else
+      } else
       {
         RECTL rect;
-        HPS hps = WinBeginPaint(hwnd,0,&rect);
-
+        HPS hps;
+
+        RestoreOS2TIB();
+        OldFrameProc(hwnd,msg,mp1,mp2);
+        SetWin32TIB();
+
+        WinQueryWindowRect(hwnd,&rect);
+        rect.xRight = rect.xRight-rect.xLeft;
+        rect.yTop = rect.yTop-rect.yBottom;
+        rect.xLeft = rect.yBottom = 0;
+        hps = WinGetClipPS(hwnd,0,PSF_CLIPCHILDREN);
         DrawFrame(hps,&rect,win32wnd);
-        WinFillRect(hps,&rect,SYSCLR_DIALOGBACKGROUND);
-        WinEndPaint(hps);
+        WinReleasePS(hps);
 
         RestoreOS2TIB();
         return (MRESULT)0;
       }
-#endif
 
     default:
Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 1332)
+++ trunk/src/user32/pmwindow.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.32 1999-10-16 18:56:51 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.33 1999-10-17 12:17:44 cbratschi Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -257,5 +257,5 @@
 
         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
-	if (!win32wnd->CanReceiveSizeMsgs())	break;
+        if (!win32wnd->CanReceiveSizeMsgs())    break;
 
         WinQueryWindowPos(hwnd, &swpOld);
@@ -263,9 +263,9 @@
         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
             if (win32wnd->isChild()) {
-		if(win32wnd->getParent()) {
-                	hParent = win32wnd->getParent()->getOS2WindowHandle();
-		}
-		else	break;
-	    }
+                if(win32wnd->getParent()) {
+                        hParent = win32wnd->getParent()->getOS2WindowHandle();
+                }
+                else    break;
+            }
             else
                 hFrame = win32wnd->getOS2FrameWindowHandle();
@@ -297,12 +297,12 @@
 
         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
-	if (!win32wnd->CanReceiveSizeMsgs())	break;
+        if (!win32wnd->CanReceiveSizeMsgs())    break;
 
         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
             if (win32wnd->isChild()) {
-		if(win32wnd->getParent()) {
-                	hParent = win32wnd->getParent()->getOS2WindowHandle();
-		}
-		else	goto RunDefWndProc; //parent has just been destroyed
+                if(win32wnd->getParent()) {
+                        hParent = win32wnd->getParent()->getOS2WindowHandle();
+                }
+                else    goto RunDefWndProc; //parent has just been destroyed
             }
             else
@@ -311,18 +311,18 @@
         OSLibMapSWPtoWINDOWPOS(pswp, &wp, pswpo, hParent, hFrame);
 
-	SWP swpFrame;
+        SWP swpFrame;
         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swpFrame);
         dprintf(("WINDOWPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), win32wnd->getOS2FrameWindowHandle(),
                          swpFrame.fl,swpFrame.x, swpFrame.y, swpFrame.cx, swpFrame.cy));
-	POINTL point;
-
-	point.x = swpFrame.x;
-	point.y = swpFrame.y;
-	if(win32wnd->getParent() != NULL)
-	{
-		WinMapWindowPoints(WinQueryWindow(hwnd, QW_PARENT), HWND_DESKTOP,
-                	           &point, 1);
-	}
-	point.y = OSLibQueryScreenHeight() - point.y - swpFrame.cy;
+        POINTL point;
+
+        point.x = swpFrame.x;
+        point.y = swpFrame.y;
+        if(win32wnd->getParent() != NULL)
+        {
+                WinMapWindowPoints(WinQueryWindow(hwnd, QW_PARENT), HWND_DESKTOP,
+                                   &point, 1);
+        }
+        point.y = OSLibQueryScreenHeight() - point.y - swpFrame.cy;
         win32wnd->setWindowRect(point.x, point.y, point.x+swpFrame.cx, point.y+swpFrame.cy);
         win32wnd->setClientRect(pswpo->x, pswpo->y, pswpo->x + pswpo->cx, pswpo->y + pswpo->cy);
@@ -614,4 +614,5 @@
     //Slider messages
     //**************************************************************************
+/* CB: handled internally
     case WM_VSCROLL:
     case WM_HSCROLL:
@@ -630,4 +631,5 @@
     break;
     }
+*/
 
     case WM_CONTROL:
@@ -845,5 +847,5 @@
     case WM_ERASEBACKGROUND:
     {
-	dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
+        dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
         if (!win32wnd->isSupressErase()) {
             BOOL erased = sendEraseBkgnd (win32wnd);
@@ -916,2 +918,58 @@
 //******************************************************************************
 //******************************************************************************
+MRESULT EXPENTRY Win32SubclassWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
+{
+  Win32BaseWindow* win32wnd;
+
+  //Restore our FS selector
+  SetWin32TIB();
+
+  win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
+
+  if (!win32wnd)
+  {
+    dprintf(("Invalid win32wnd pointer for subclassed window %x!!", hwnd));
+    goto RunDefWndProc;
+  }
+
+  switch (msg)
+  {
+    case WM_WINDOWPOSCHANGED:
+      {
+        PSWP      pswp  = (PSWP)mp1;
+        PSWP      pswpo = pswp + 1;
+        WINDOWPOS wp;
+        HWND      hParent = NULLHANDLE, hFrame = NULLHANDLE;
+
+        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) break;
+
+        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
+          hFrame = WinQueryWindow(hwnd, QW_PARENT);
+
+        OSLibMapSWPtoWINDOWPOS(pswp,&wp,pswpo,hParent,hFrame);
+        win32wnd->MsgPosChanged((LPARAM)&wp);
+
+        goto RunOldWndProc;
+      }
+
+    default:
+      goto RunDefHandler;
+  }
+
+RunDefWndProc:
+  RestoreOS2TIB();
+  return WinDefWindowProc(hwnd,msg,mp1,mp2);
+
+RunOldWndProc:
+  RestoreOS2TIB();
+  return ((PFNWP)win32wnd->getOldWndProc())(hwnd,msg,mp1,mp2);
+
+RunDefHandler:
+  RestoreOS2TIB();
+  return Win32WindowProc(hwnd,msg,mp1,mp2);
+}
+
+PVOID SubclassWithDefHandler(HWND hwnd)
+{
+  return WinSubclassWindow(hwnd,Win32SubclassWindowProc);
+}
Index: trunk/src/user32/pmwindow.h
===================================================================
--- trunk/src/user32/pmwindow.h	(revision 1332)
+++ trunk/src/user32/pmwindow.h	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.h,v 1.1 1999-09-15 23:18:55 sandervl Exp $ */
+/* $Id: pmwindow.h,v 1.2 1999-10-17 12:17:44 cbratschi Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -9,7 +9,9 @@
 #define __PMWINDOW_H__
 
-#define WIN32_STDCLASS	"Win32WindowClass"
+#define WIN32_STDCLASS  "Win32WindowClass"
 
 BOOL InitPM();
+
+PVOID SubclassWithDefHandler(HWND hwnd);
 
 void RegisterSystemClasses(ULONG hModule);
Index: trunk/src/user32/scroll.cpp
===================================================================
--- trunk/src/user32/scroll.cpp	(revision 1332)
+++ trunk/src/user32/scroll.cpp	(revision 1333)
@@ -1,7 +1,7 @@
-/* $Id: scroll.cpp,v 1.8 1999-10-15 09:26:23 sandervl Exp $ */
+/* $Id: scroll.cpp,v 1.9 1999-10-17 12:17:44 cbratschi Exp $ */
 /*
  * Scrollbar control
  *
- * Copyright 1999 Christoph Bratschi (ported from WINE)
+ * Copyright 1999 Christoph Bratschi
  *
  * Copyright 1993 Martin Ayotte
@@ -10,11 +10,4 @@
  * WINE version: 990923
  */
-
-/* CB:
-  - exported API removed, this functions are already implemented by Open32,
-    code perhaps useful for new user32
-  - only control, default scroll bars for windows need more work
-  - SystemTimer not implemented
-*/
 
 #include <stdlib.h>
@@ -24,4 +17,6 @@
 #include "win32wbase.h"
 #include "oslibwin.h"
+
+static BOOL bitmapsLoaded = FALSE;
 
 static HBITMAP hUpArrow = 0;
@@ -112,4 +107,6 @@
 {
     HINSTANCE hinst;
+
+    if (bitmapsLoaded) return;
 
     //CB: Open32 hack to load our own bitmap
@@ -128,64 +125,32 @@
     hRgArrowI = NativeLoadBitmap( hinst, MAKEINTRESOURCEA(OBM_RGARROWI) );
     FreeLibrary(hinst);
+
+    bitmapsLoaded = TRUE;
 }
 
 /***********************************************************************
- *           SCROLL_GetPtrScrollInfo
- */
-static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( HWND hwnd, INT nBar )
-{
-    SCROLLBAR_INFO *infoPtr;
+ *           SCROLL_GetInfoPtr
+ */
+static SCROLLBAR_INFO *SCROLL_GetInfoPtr( HWND hwnd, INT nBar )
+{
+    Win32BaseWindow *win32wnd;
+    HWND hwndFrame;
 
     switch(nBar)
     {
-/* CB: implement this later!
         case SB_HORZ:
-          infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll;
-          break;
         case SB_VERT:
-          infoPtr = (SCROLLBAR_INFO *)wndPtr->pVScroll;
-          break;
-*/
+          win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+          if (!win32wnd) return NULL;
+          hwndFrame = OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_PARENT);
+          win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndFrame);
+          if (!win32wnd) return NULL;
+          return win32wnd->getScrollInfo(nBar);
+
         case SB_CTL:
-          infoPtr = (SCROLLBAR_INFO *)GetInfoPtr(hwnd);
-          break;
-        default:      return NULL;
-    }
-
-    if (!infoPtr)  /* Create the info structure if needed */
-    {
-        infoPtr = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
-        infoPtr->MinVal = infoPtr->CurVal = infoPtr->Page = 0;
-        infoPtr->MaxVal = 100;
-        infoPtr->flags  = ESB_ENABLE_BOTH;
-
-        //CB: store in window class if not control!
-        SetInfoPtr(hwnd,(DWORD)infoPtr);
-
-        if (!hUpArrow) SCROLL_LoadBitmaps();
-    }
-    return infoPtr;
-}
-
-
-/***********************************************************************
- *           SCROLL_GetScrollInfo
- */
-static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar )
-{
- Win32BaseWindow *window;
-
-    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
-    if(!window && nBar != SB_CTL) {
-        dprintf(("SCROLL_GetScrollInfo window %x not found!", hwnd));
-        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
-        return NULL;
-    }
-
-    if (window) {
-            return window->getScrollInfo(nBar);
-    }
-
-    return SCROLL_GetPtrScrollInfo( hwnd, nBar );
+          return (SCROLLBAR_INFO*)GetInfoPtr(hwnd);
+    }
+
+    return NULL;
 }
 
@@ -208,40 +173,22 @@
     INT pixels;
     BOOL vertical;
-    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     RECT rectClient;
 
     switch(nBar)
     {
-/* CB: implement later!
       case SB_HORZ:
-        lprect->left   = wndPtr->rectClient.left - wndPtr->rectWindow.left;
-        lprect->top    = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
-        lprect->right  = wndPtr->rectClient.right - wndPtr->rectWindow.left;
-        lprect->bottom = lprect->top + GetSystemMetrics(SM_CYHSCROLL);
-        if(dwStyle & WS_BORDER) {
-          lprect->left--;
-          lprect->right++;
-        } else if(dwStyle & WS_VSCROLL)
-          lprect->right++;
-        vertical = FALSE;
+      case SB_VERT:
+        GetClientRect( hwnd, lprect );
+        vertical = (nBar == SB_VERT);
         break;
 
-      case SB_VERT:
-        lprect->left   = wndPtr->rectClient.right - wndPtr->rectWindow.left;
-        lprect->top    = wndPtr->rectClient.top - wndPtr->rectWindow.top;
-        lprect->right  = lprect->left + GetSystemMetrics(SM_CXVSCROLL);
-        lprect->bottom = wndPtr->rectClient.bottom - wndPtr->rectWindow.top;
-        if(wndPtr->dwStyle & WS_BORDER) {
-          lprect->top--;
-          lprect->bottom++;
-        } else if(wndPtr->dwStyle & WS_HSCROLL)
-          lprect->bottom++;
-        vertical = TRUE;
-        break;
-*/
       case SB_CTL:
-        GetClientRect( hwnd, lprect );
-        vertical = ((dwStyle & SBS_VERT) != 0);
-        break;
+        {
+          DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
+
+          GetClientRect( hwnd, lprect );
+          vertical = ((dwStyle & SBS_VERT) != 0);
+          break;
+        }
 
     default:
@@ -262,5 +209,5 @@
     else
     {
-        SCROLLBAR_INFO *info = SCROLL_GetPtrScrollInfo( hwnd, nBar );
+        SCROLLBAR_INFO *info = SCROLL_GetInfoPtr( hwnd, nBar );
 
         *arrowSize = GetSystemMetrics(SM_CXVSCROLL);
@@ -454,5 +401,5 @@
  * Draw the moving thumb rectangle.
  */
-static void SCROLL_DrawMovingThumb_9x( HDC hdc, RECT *rect, BOOL vertical,
+static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
                        INT arrowSize, INT thumbSize )
 {
@@ -477,11 +424,4 @@
 
   SCROLL_MovingThumb = !SCROLL_MovingThumb;
-}
-//******************************************************************************
-//******************************************************************************
-static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
-                    INT arrowSize, INT thumbSize )
-{
-  SCROLL_DrawMovingThumb_9x( hdc, rect, vertical, arrowSize, thumbSize );
 }
 /***********************************************************************
@@ -511,6 +451,6 @@
     else
     {
-      //CB: implement!
-      //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
+      hBrush = (HBRUSH)SendMessageA( hwnd, WM_CTLCOLORSCROLLBAR,
+                     (WPARAM)hdc,(LPARAM)hwnd);
     }
 
@@ -591,4 +531,7 @@
     BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
 
+//SCROLL_DrawInterior_9x(hwnd,hdc,nBar,rect,arrowSize,thumbSize,thumbPos,flags,vertical,top_selected,bottom_selected);
+//return; //CB: improve!
+
     if (Save_SCROLL_MovingThumb &&
         (SCROLL_TrackingWin == hwnd) &&
@@ -606,6 +549,7 @@
                                        (WPARAM)hdc,(LPARAM)hwnd);
     } else {
-        //CB: implement!
-        //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
+        hBrush = (HBRUSH)SendMessageA( hwnd, WM_CTLCOLORSCROLLBAR,
+                                       (WPARAM)hdc,(LPARAM)hwnd);
+
     }
 
@@ -706,12 +650,6 @@
     RECT rect;
     BOOL vertical;
-    SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( hwnd, nBar );
+    SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr( hwnd, nBar );
     BOOL Save_SCROLL_MovingThumb = SCROLL_MovingThumb;
-    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
-
-    if (!infoPtr ||
-        ((nBar == SB_VERT) && !(dwStyle & WS_VSCROLL)) ||
-        ((nBar == SB_HORZ) && !(dwStyle & WS_HSCROLL))) return;
-    //if (!WIN_IsWindowDrawable( hwnd, FALSE )) return; //CB: what's that???
 
     vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
@@ -754,6 +692,13 @@
                                      BOOL arrows, BOOL interior )
 {
-    HDC hdc = GetDCEx( hwnd, 0,
-                           DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) );
+    //HDC hdc = GetDCEx( hwnd, 0,
+    //                       DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW) );
+HDC hdc;
+
+return;
+//CB: bug: paints in client window!
+//    GetClientRect returns wrong window size after GetDC
+//    why?!?
+
     if (!hdc) return;
 
@@ -811,13 +756,24 @@
     HDC hdc;
 
-    SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
+    SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr( hwnd, nBar );
     if (!infoPtr) return;
     if ((SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN))
                   return;
 
-    hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
     vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
                                         &arrowSize, &thumbSize, &thumbPos );
-    hwndOwner = (nBar == SB_CTL) ? GetParent(hwnd) : hwnd;
+    if (nBar == SB_CTL) hwndOwner = GetParent(hwnd); else
+    {
+      Win32BaseWindow *win32wnd;
+      HWND hwndFrame;
+
+      win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+      if (!win32wnd) return;
+      hwndFrame = OSLibWinQueryWindow(win32wnd->getOS2WindowHandle(),QWOS_PARENT);
+      win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndFrame);
+      if (!win32wnd) return;
+      hwndOwner = win32wnd->getWindowHandle();
+    }
+
     hwndCtl   = (nBar == SB_CTL) ? hwnd : 0;
 
@@ -854,4 +810,6 @@
     }
 
+    hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
+
     //TRACE("Event: hwnd=%04x bar=%d msg=%x pt=%ld,%ld hit=%d\n",
     //             hwnd, nBar, msg, pt.x, pt.y, hittest );
@@ -872,9 +830,9 @@
                                 SB_LINEUP, hwndCtl );
             }
-            //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
-            //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
-            //                  (TIMERPROC)0 );
-        }
-        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
+            SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
+                            SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
+                            (TIMERPROC)0 );
+        }
+        else KillSystemTimer( hwnd, SCROLL_TIMER );
         break;
 
@@ -889,10 +847,10 @@
                 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
                                 SB_PAGEUP, hwndCtl );
-                //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
-                //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
-                //                  (TIMERPROC)0 );
+                SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
+                                SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
+                                (TIMERPROC)0 );
             }
         }
-        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
+        else KillSystemTimer( hwnd, SCROLL_TIMER );
         break;
 
@@ -955,10 +913,10 @@
                 SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
                                 SB_PAGEDOWN, hwndCtl );
-                //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
-                //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
-                //                  (TIMERPROC)0 );
+                SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
+                                SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
+                                (TIMERPROC)0 );
             }
         }
-        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
+        else KillSystemTimer( hwnd, SCROLL_TIMER );
         break;
 
@@ -973,9 +931,9 @@
                                 SB_LINEDOWN, hwndCtl );
             }
-            //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
-            //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
-            //                  (TIMERPROC)0 );
-        }
-        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
+            SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
+                            SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
+                            (TIMERPROC)0 );
+        }
+        else KillSystemTimer( hwnd, SCROLL_TIMER );
         break;
     }
@@ -1008,4 +966,18 @@
     switch(message)
     {
+    case WM_NCCREATE:
+      {
+        SCROLLBAR_INFO *infoPtr = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
+
+        infoPtr->MinVal = infoPtr->CurVal = infoPtr->Page = 0;
+        infoPtr->MaxVal = 100;
+        infoPtr->flags  = ESB_ENABLE_BOTH;
+
+        SetInfoPtr(hwnd,(DWORD)infoPtr);
+
+        if (!bitmapsLoaded) SCROLL_LoadBitmaps();
+
+        return TRUE;
+      }
     case WM_CREATE:
         {
@@ -1014,5 +986,5 @@
             {
                 //FIXME("Unimplemented style SBS_SIZEBOX.\n" );
-                return 0;
+                return 0; //CB: implement! (for frames/toolbar already done)
             }
 
@@ -1040,5 +1012,5 @@
             }
         }
-        if (!hUpArrow) SCROLL_LoadBitmaps();
+
         //TRACE("ScrollBar creation, hwnd=%04x\n", hwnd );
         return 0;
@@ -1081,6 +1053,11 @@
 
     case SBM_SETRANGE:
-        SetScrollRange( hwnd, SB_CTL, wParam, lParam, FALSE );
-        return 0;  /* FIXME: return previous position */
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_CTL);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_CTL,wParam,lParam,FALSE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
 
     case SBM_GETRANGE:
@@ -1092,6 +1069,11 @@
 
     case SBM_SETRANGEREDRAW:
-        SetScrollRange( hwnd, SB_CTL, wParam, lParam, TRUE );
-        return 0;  /* FIXME: return previous position */
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_CTL);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_CTL,wParam,lParam,TRUE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
 
     case SBM_SETSCROLLINFO:
@@ -1114,11 +1096,177 @@
 
     default:
-//SvL: BUGFIX: Send WM_NCCREATE to defwndproc, return value 0 cancels window creation!
-//        if (message >= WM_USER)
-            //WARN("unknown msg %04x wp=%04x lp=%08lx\n",
-            //             message, wParam, lParam );
-        return DefWindowProcA( hwnd, message, wParam, lParam );
+      return DefWindowProcA( hwnd, message, wParam, lParam );
     }
     return 0;
+}
+
+/* frame handlers */
+
+VOID SCROLL_SubclassScrollBars(HWND hwndHorz,HWND hwndVert)
+{
+  if (hwndHorz)
+  {
+    SetWindowLongA(hwndHorz,GWL_WNDPROC,(ULONG)HorzScrollBarWndProc);
+    //windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
+//    InvalidateRect(hwndHorz,NULL,FALSE);
+  }
+
+  if (hwndVert)
+  {
+    SetWindowLongA(hwndVert,GWL_WNDPROC,(ULONG)VertScrollBarWndProc);
+//    InvalidateRect(hwndVert,NULL,FALSE);
+  }
+
+  if (!bitmapsLoaded) SCROLL_LoadBitmaps();
+}
+
+LRESULT WINAPI HorzScrollBarWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam )
+{
+  switch (message)
+  {
+    case WM_LBUTTONDOWN:
+    case WM_LBUTTONUP:
+    case WM_MOUSEMOVE:
+    case WM_SYSTIMER:
+        {
+            POINT pt;
+            CONV_POINT16TO32( (POINT16 *)&lParam, &pt );
+            SCROLL_HandleScrollEvent( hwnd, SB_HORZ, message, pt );
+        }
+        break;
+
+    case WM_ERASEBKGND:
+         return 1;
+
+    case WM_GETDLGCODE:
+         return DLGC_WANTARROWS; /* Windows returns this value */
+
+    case WM_PAINT:
+      {
+        PAINTSTRUCT ps;
+
+        HDC hdc = BeginPaint( hwnd, &ps );
+        SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
+        EndPaint( hwnd, &ps );
+      }
+      break;
+
+    case SBM_SETPOS:
+      return SetScrollPos( hwnd, SB_HORZ, wParam, (BOOL)lParam );
+
+    case SBM_GETPOS:
+        return GetScrollPos( hwnd, SB_HORZ );
+
+    case SBM_SETRANGE:
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_HORZ);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_HORZ,wParam,lParam,FALSE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
+
+    case SBM_GETRANGE:
+        GetScrollRange( hwnd, SB_HORZ, (LPINT)wParam, (LPINT)lParam );
+        return 0;
+
+    case SBM_ENABLE_ARROWS:
+        return EnableScrollBar( hwnd, SB_HORZ, wParam );
+
+    case SBM_SETRANGEREDRAW:
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_HORZ);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_HORZ,wParam,lParam,TRUE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
+
+    case SBM_SETSCROLLINFO:
+        return SetScrollInfo( hwnd, SB_HORZ, (SCROLLINFO *)lParam, wParam );
+
+    case SBM_GETSCROLLINFO:
+        return GetScrollInfo( hwnd, SB_HORZ, (SCROLLINFO *)lParam );
+
+    default:
+      return DefWindowProcA(hwnd,message,wParam,lParam);
+  }
+
+  return 0;
+}
+
+LRESULT WINAPI VertScrollBarWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam )
+{
+  switch (message)
+  {
+    case WM_LBUTTONDOWN:
+    case WM_LBUTTONUP:
+    case WM_MOUSEMOVE:
+    case WM_SYSTIMER:
+        {
+            POINT pt;
+            CONV_POINT16TO32( (POINT16 *)&lParam, &pt );
+            SCROLL_HandleScrollEvent( hwnd, SB_VERT, message, pt );
+        }
+        break;
+
+    case WM_ERASEBKGND:
+         return 1;
+
+    case WM_GETDLGCODE:
+         return DLGC_WANTARROWS; /* Windows returns this value */
+
+    case WM_PAINT:
+      {
+        PAINTSTRUCT ps;
+
+        HDC hdc = BeginPaint( hwnd, &ps );
+        SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
+        EndPaint( hwnd, &ps );
+      }
+      break;
+
+    case SBM_SETPOS:
+      return SetScrollPos( hwnd, SB_VERT, wParam, (BOOL)lParam );
+
+    case SBM_GETPOS:
+        return GetScrollPos( hwnd, SB_VERT );
+
+    case SBM_SETRANGE:
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_VERT);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_VERT,wParam,lParam,FALSE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
+
+    case SBM_GETRANGE:
+        GetScrollRange( hwnd, SB_VERT, (LPINT)wParam, (LPINT)lParam );
+        return 0;
+
+    case SBM_ENABLE_ARROWS:
+        return EnableScrollBar( hwnd, SB_VERT, wParam );
+
+    case SBM_SETRANGEREDRAW:
+        {
+          SCROLLBAR_INFO *infoPtr = SCROLL_GetInfoPtr(hwnd,SB_VERT);
+          INT oldPos = infoPtr->CurVal;
+
+          SetScrollRange(hwnd,SB_VERT,wParam,lParam,TRUE);
+          return (oldPos != infoPtr->CurVal) ? infoPtr->CurVal:0;
+        }
+
+    case SBM_SETSCROLLINFO:
+        return SetScrollInfo( hwnd, SB_VERT, (SCROLLINFO *)lParam, wParam );
+
+    case SBM_GETSCROLLINFO:
+        return GetScrollInfo( hwnd, SB_VERT, (SCROLLINFO *)lParam );
+
+    default:
+      return DefWindowProcA(hwnd,message,wParam,lParam);
+  }
+
+  return 0;
 }
 
@@ -1148,4 +1296,5 @@
   INT retVal;
 
+/* CB: handled here, todo: hide/show
     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     if(!window && nBar != SB_CTL) {
@@ -1157,4 +1306,5 @@
         return window->setScrollInfo(nBar, (SCROLLINFO *)info, bRedraw);
     }
+*/
 
     retVal = SCROLL_SetScrollInfo( hwnd, nBar, info, &action );
@@ -1187,5 +1337,5 @@
    *action = 0;
 
-    if (!(infoPtr = SCROLL_GetScrollInfo(hwnd, nBar))) return 0;
+    if (!(infoPtr = SCROLL_GetInfoPtr(hwnd, nBar))) return 0;
     if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
     if ((info->cbSize != sizeof(*info)) &&
@@ -1303,5 +1453,5 @@
   SCROLLBAR_INFO *infoPtr;
 
-    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
+    if (!(infoPtr = SCROLL_GetInfoPtr( hwnd, nBar ))) return FALSE;
     if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return FALSE;
     if ((info->cbSize != sizeof(*info)) &&
@@ -1341,5 +1491,5 @@
 
     dprintf(("SetScrollPos %x %d %d %d", hwnd, nBar, nPos, bRedraw));
-    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
+    if (!(infoPtr = SCROLL_GetInfoPtr( hwnd, nBar ))) return 0;
     oldPos      = infoPtr->CurVal;
     info.cbSize = sizeof(info);
@@ -1368,5 +1518,5 @@
     dprintf(("GetScrollPos %x %d", hwnd, nBar));
 
-    infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
+    infoPtr = SCROLL_GetInfoPtr( hwnd, nBar );
     if (!infoPtr) return 0;
 
@@ -1442,5 +1592,5 @@
   SCROLLBAR_INFO *infoPtr;
 
-    infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
+    infoPtr = SCROLL_GetInfoPtr( hwnd, nBar );
     if (!infoPtr)
     {
@@ -1617,5 +1767,5 @@
     if (nBar == SB_BOTH)
     {
-        if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, SB_VERT ))) return FALSE;
+        if (!(infoPtr = SCROLL_GetInfoPtr( hwnd, SB_VERT ))) return FALSE;
         if (!(bFineWithMe = (infoPtr->flags == flags)) )
         {
@@ -1628,5 +1778,5 @@
         bFineWithMe = TRUE;
 
-    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
+    if (!(infoPtr = SCROLL_GetInfoPtr( hwnd, nBar ))) return FALSE;
     if (bFineWithMe && infoPtr->flags == flags) return FALSE;
     infoPtr->flags = flags;
Index: trunk/src/user32/user32exp.def
===================================================================
--- trunk/src/user32/user32exp.def	(revision 1332)
+++ trunk/src/user32/user32exp.def	(revision 1333)
@@ -565,4 +565,6 @@
     _wvsprintfA@12                            @579
     _wvsprintfW@12                            @580
+    _GetMenuInfo@8                            @800
+    _SetMenuInfo@8                            @801
     _GetMonitorInfoW@8                        @1000
     _GetMonitorInfoA@8                        @1001
Index: trunk/src/user32/win32dlg.cpp
===================================================================
--- trunk/src/user32/win32dlg.cpp	(revision 1332)
+++ trunk/src/user32/win32dlg.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: win32dlg.cpp,v 1.15 1999-10-16 11:05:38 sandervl Exp $ */
+/* $Id: win32dlg.cpp,v 1.16 1999-10-17 12:17:44 cbratschi Exp $ */
 /*
  * Win32 Dialog Code for OS/2
@@ -261,4 +261,32 @@
         ShowWindow( SW_SHOW );
 
+        //CB: 100% CPU usage, need a better solution with OSLibWinGetMsg
+        //    is WM_ENTERIDLE used and leaving away breaks an application?
+        //    this style was useful for Win3.1 but today there are threads
+        // solution: send only few WM_ENTERIDLE messages
+
+#if 1
+        while (TRUE)
+        {
+          if (!OSLibWinPeekMsg(&msg,0,0,0,MSG_NOREMOVE))
+          {
+            if(!(getStyle() & DS_NOIDLEMSG))
+              topOwner->SendMessageA(WM_ENTERIDLE,MSGF_DIALOGBOX,getWindowHandle());
+            OSLibWinGetMsg(&msg,0,0,0);
+          } else OSLibWinPeekMsg(&msg,0,0,0,MSG_REMOVE);
+
+          if(msg.message == WM_QUIT)
+          {
+            dprintf(("Win32Dialog::doDialogBox: received  WM_QUIT"));
+            break;
+          }
+          if (!IsDialogMessageA( getWindowHandle(), &msg))
+          {
+            TranslateMessage( &msg );
+            DispatchMessageA( &msg );
+          }
+          if (dialogFlags & DF_END) break;
+        }
+#else
         while (TRUE) {
 //        while (OSLibWinPeekMsg(&msg, getWindowHandle(), owner, MSGF_DIALOGBOX,
@@ -284,4 +312,5 @@
             }
         }
+#endif
         topOwner->EnableWindow( TRUE );
     }
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 1332)
+++ trunk/src/user32/win32wbase.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.47 1999-10-16 14:51:42 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.48 1999-10-17 12:17:45 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -40,4 +40,5 @@
 #include "pmframe.h"
 #include "win32wdesktop.h"
+#include "pmwindow.h"
 #include <wprocess.h>
 
@@ -85,4 +86,37 @@
 //******************************************************************************
 //******************************************************************************
+Win32BaseWindow::Win32BaseWindow(HWND os2Handle,VOID* win32WndProc) : GenericObject(&windows,OBJTYPE_WINDOW)
+{
+  Init();
+  OS2Hwnd = OS2HwndFrame = os2Handle;
+  dwStyle = WS_VISIBLE;
+  setWindowProc((WNDPROC)win32WndProc);
+  fIsSubclassedOS2Wnd = TRUE;
+  fFirstShow = FALSE;
+
+  //CB: replace by a secure method
+
+  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
+        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
+        SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
+        return;
+  }
+  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
+        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
+        SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
+        return;
+  }
+
+  OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow);
+  rectClient = rectWindow;
+  rectClient.bottom -= rectClient.top;
+  rectClient.top = 0;
+  rectClient.right -= rectClient.left;
+  rectClient.left = 0;
+
+  setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
+}
+//******************************************************************************
+//******************************************************************************
 Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
                         : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
@@ -97,4 +131,5 @@
 {
   isUnicode        = FALSE;
+  fIsSubclassedOS2Wnd = FALSE;
   fFirstShow       = TRUE;
   fIsDialog        = FALSE;
@@ -200,8 +235,4 @@
         horzScrollInfo = NULL;
     }
-  //TODO: Destroy windows if they're not associated with our window anymore (showwindow false)?
-//  hwndHorzScroll
-//  hwndVertScroll
-
 }
 //******************************************************************************
@@ -584,4 +615,7 @@
   }
 
+  //CB: switch off -> OS/2 scrollbars
+  subclassScrollBars(dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
+
   fakeWinBase.hwndThis     = OS2Hwnd;
   fakeWinBase.pWindowClass = windowClass;
@@ -690,4 +724,6 @@
  Win32BaseWindow *child;
 
+    if (isSubclassedOS2Wnd) OSLibWinSubclassWindow(OS2Hwnd,pOldWndProc);
+
     //According to the SDK, WM_PARENTNOTIFY messages are sent to the parent (this window)
     //before any window destruction has begun
@@ -699,4 +735,7 @@
     }
     SendInternalMessageA(WM_DESTROY, 0, 0);
+
+    if (hwndHorzScroll && OSLibWinQueryWindow(hwndHorzScroll,QWOS_PARENT) == OSLIB_HWND_OBJECT) OSLibWinDestroyWindow(hwndHorzScroll);
+    if (hwndVertScroll && OSLibWinQueryWindow(hwndVertScroll,QWOS_PARENT) == OSLIB_HWND_OBJECT) OSLibWinDestroyWindow(hwndVertScroll);
 
     fIsDestroyed = TRUE;
@@ -1007,5 +1046,5 @@
                 break;
         case BUTTON_LEFTDBLCLICK:
-                if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
+                if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
                 {
                   win32msg = WM_LBUTTONDBLCLK;
@@ -1026,5 +1065,5 @@
                 break;
         case BUTTON_RIGHTDBLCLICK:
-                if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
+                if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
                 {
                   win32msg = WM_RBUTTONDBLCLK;
@@ -1045,5 +1084,5 @@
                 break;
         case BUTTON_MIDDLEDBLCLICK:
-                if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
+                if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
                 {
                   win32msg = WM_MBUTTONDBLCLK;
@@ -1186,5 +1225,5 @@
     case SB_HORZ:
         if(horzScrollInfo) {
-            horzScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndHorzScroll);
+            //CB:horzScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndHorzScroll);
             return horzScrollInfo;
         }
@@ -1192,5 +1231,5 @@
     case SB_VERT:
         if(vertScrollInfo) {
-            vertScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndVertScroll);
+            //CB:vertScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndVertScroll);
             return vertScrollInfo;
         }
@@ -1208,4 +1247,7 @@
   ULONG           scrollType;
   int             new_flags;
+
+//CB: handled internally
+return 0;
 
     switch(nBar) {
@@ -1327,4 +1369,10 @@
     return infoPtr->CurVal;
 }
+/***********************************************************************/
+/***********************************************************************/
+VOID Win32BaseWindow::subclassScrollBars(BOOL subHorz,BOOL subVert)
+{
+  SCROLL_SubclassScrollBars(subHorz ? hwndHorzScroll:0,subVert ? hwndVertScroll:0);
+}
 /***********************************************************************
  *           NC_HandleSysCommand
@@ -1567,5 +1615,5 @@
       int rc;
 
-        if (!windowClass->getBackgroundBrush()) return 0;
+        if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
 
         rc = GetClipBox( (HDC)wParam, &rect );
@@ -1625,4 +1673,5 @@
     {
             LRESULT result = 0;
+            if (!windowClass) return result;
             int index = GCL_HICON;
 
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 1332)
+++ trunk/src/user32/win32wbase.h	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.25 1999-10-16 14:51:43 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.26 1999-10-17 12:17:45 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -58,4 +58,5 @@
 
                 Win32BaseWindow(DWORD objType);
+                Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
                 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
 virtual        ~Win32BaseWindow();
@@ -163,7 +164,6 @@
          BOOL   IsWindow()                    { return TRUE; };
          BOOL   IsDialog()                    { return fIsDialog; };
-
-	 BOOL   CanReceiveSizeMsgs()          { return !fNoSizeMsg; };
-	 BOOL   IsWindowDestroyed()           { return fIsDestroyed; };
+         BOOL   CanReceiveSizeMsgs()          { return !fNoSizeMsg; };
+         BOOL   IsWindowDestroyed()           { return fIsDestroyed; };
          BOOL   IsWindowEnabled();
          BOOL   IsWindowVisible();
@@ -185,4 +185,5 @@
        HWND      getVertScrollHandle()        { return hwndVertScroll; };
        HWND      getHorzScrollHandle()        { return hwndHorzScroll; };
+       VOID      subclassScrollBars(BOOL subHorz,BOOL subVert);
 
        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
@@ -212,4 +213,8 @@
        ULONG getBorderWidth() { return borderWidth; };
        ULONG getBorderHeight() { return borderHeight; };
+
+       PVOID getOldWndProc() { return pOldWndProc; }
+       VOID  setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
+       BOOL  isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
 
 protected:
@@ -249,10 +254,13 @@
         BOOL    fInternalMsg;           //Used to distinguish between messages
                                         //sent by PM and those sent by apps
-	BOOL    fNoSizeMsg;
-	BOOL    fIsDestroyed;
+        BOOL    fNoSizeMsg;
+        BOOL    fIsDestroyed;
 
         PVOID   pOldFrameProc;
         ULONG   borderWidth;
         ULONG   borderHeight;
+
+        PVOID   pOldWndProc;
+        BOOL    fIsSubclassedOS2Wnd;  //subclassed OS/2 window: Netscape plug-in/scrollbar
 
    Win32BaseWindow *owner;
@@ -286,5 +294,5 @@
 #ifndef OS2_INCLUDED
         void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
-	LONG  HandleSysCommand(WPARAM wParam, POINT *pt32);
+        LONG  HandleSysCommand(WPARAM wParam, POINT *pt32);
 
         LONG  SendNCCalcSize(BOOL calcValidRect,
@@ -293,5 +301,5 @@
                              RECT *newClientRect );
 
- 	LONG  NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
+        LONG  NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
 
      LRESULT  SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
@@ -309,5 +317,5 @@
          fakeOpen32WinBaseClass fakeWinBase;
 
-         BOOL   isOwnDC() { return (windowClass->getStyle() & CS_OWNDC_W); }
+         BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
          HDC    getOwnDC() { return ownDC; }
          void   setOwnDC(HDC hdc) { ownDC = hdc; }
Index: trunk/src/user32/windowword.cpp
===================================================================
--- trunk/src/user32/windowword.cpp	(revision 1332)
+++ trunk/src/user32/windowword.cpp	(revision 1333)
@@ -1,3 +1,3 @@
-/* $Id: windowword.cpp,v 1.1 1999-09-15 23:19:03 sandervl Exp $ */
+/* $Id: windowword.cpp,v 1.2 1999-10-17 12:17:46 cbratschi Exp $ */
 
 /*
@@ -17,5 +17,5 @@
 //******************************************************************************
 //******************************************************************************
-LONG WIN32API SetWindowLongA(HWND hwnd, int nIndex, LONG  arg3)
+LONG WIN32API SetWindowLongA(HWND hwnd, int nIndex, LONG  lNewLong)
 {
  Win32BaseWindow *window;
@@ -24,9 +24,28 @@
     if(window)
     {
-    return window->SetWindowLongA(nIndex, arg3);
-    }
-    else
+      return window->SetWindowLongA(nIndex,lNewLong);
+    } else
     {
-    dprintf(("SetWindowLongA; window %x not found!", hwnd));
+      if (nIndex == GWL_WNDPROC && !Win32BaseWindow::GetWindowFromOS2Handle(hwnd))
+      {
+        dprintf(("Start subclassing OS/2 window"));
+
+        window = new Win32BaseWindow(hwnd,(PVOID)lNewLong);
+
+        if(window == NULL)
+        {
+          dprintf(("Win32BaseWindow creation failed!!"));
+          return 0;
+        }
+
+        if(GetLastError() != 0)
+        {
+          dprintf(("Win32BaseWindow error found!!"));
+          delete window;
+          return 0;
+        }
+
+        return (LONG)window->getOldWndProc();
+      } else dprintf(("SetWindowLongA; window %x not found!", hwnd));
     }
     return 0;
@@ -34,5 +53,5 @@
 //******************************************************************************
 //******************************************************************************
-LONG WIN32API SetWindowLongW(HWND hwnd, int nIndex, LONG  arg3)
+LONG WIN32API SetWindowLongW(HWND hwnd, int nIndex, LONG  lNewLong)
 {
  Win32BaseWindow *window;
@@ -41,9 +60,28 @@
     if(window)
     {
-    return window->SetWindowLongA(nIndex, arg3);
-    }
-    else
+      return window->SetWindowLongA(nIndex,lNewLong);
+    } else
     {
-    dprintf(("SetWindowLongW; window %x not found!", hwnd));
+      if (nIndex == GWL_WNDPROC && !Win32BaseWindow::GetWindowFromOS2Handle(hwnd))
+      {
+        dprintf(("Start subclassing OS/2 window"));
+
+        window = new Win32BaseWindow(hwnd,(PVOID)lNewLong);
+
+        if(window == NULL)
+        {
+          dprintf(("Win32BaseWindow creation failed!!"));
+          return 0;
+        }
+
+        if(GetLastError() != 0)
+        {
+          dprintf(("Win32BaseWindow error found!!"));
+          delete window;
+          return 0;
+        }
+
+        return (LONG)window->getOldWndProc();
+      } else dprintf(("SetWindowLongW; window %x not found!", hwnd));
     }
     return 0;
