Release 960824

Sat Aug 24 13:57:01 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/scroll.c]
	Renamed SCROLLINFO to SCROLLBAR_INFO to avoid conflict with Win32.

	* [graphics/driver.c] [include/x11drv.h]
	New files for graphics driver handling.

	* [if1632/relay.c] [include/registers.h] [tools/build.c]
	Implemented Win32 register functions. Not really tested yet.

	* [include/gdi.h]
	Added a lot of functions to the DC func table.

	* [loader/pe_image.c]
	Initialise %fs before calling out to 32-bit code.

	* [windows/hook.c]
	Fixed bug in HOOK_GetHook().

	* [windows/win.c]
	Fixed FindWindow to return an error if the class name doesn't exist.

Wed Aug 21 15:15:53 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [if1632/Makefile.in] [misc/mpr.c] [if1632/mpr.spec]
	mpr.dll specs added.

	* [if1632/kernel32.spec] [win32/newfns.c] [memory/global.c]
	QueryPerformanceCounter(), GlobalMemoryStatus() added.

	* [if1632/user32.spec] [win32/error.c]
	SetLastErrorEx() added.

	* [misc/commdlg.c]
	lpstrFilter might be NULL in FILE_WMInitDialog (NS 3.0 setup).

	* [misc/registry.c]
	Some missing NULL ptr checks added, misc clean up.

Tue Aug 20 21:00:00 1996 Alex Korobka  <alex@pharm.sunysb.edu>

	* [controls/menu.c]
	Adjust popup menu coordinates so that it always stays within 
	the desktop.

	* [misc/main.c]
	Fixed GetEnvironment() return value for lpEnv == NULL case.

Mon Aug 19 22:48:36 1996  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [misc/crtdll.c] [if1632/crtdll.spec]
	Added some is* functions, strlen and tolower.
	
Mon Aug 19 13:33:13 1996  Stephen Simmons  <ssimmons@vitsemi.com>

	* [tools/wineconf]
	New perl script to generate the wine.conf file.

Fri Aug 16 15:31:44 1996   John Harvey <john@division.co.uk>

	* [if1632/gdi.spec]
        Lots of printer functions.
	
	* [include/callback.h]
        New functions for printer driver support.

	* [include/gdi.h]
        New/changed structures to support printer driver.

	* [misc/escape.c]
        New version that uses function table in DC structure.

	* [objects/dc.c]
        CreateDC copes with things other than Display.
	X code for CreateDC moved to graphics/x11drv directory.
	CreateCompatibleDC copies func table from original DC.

	* [objects/font.c]
        GetTextExtentPoint32A,GetTextMetrics16 use function table in
        DC and code moved to drivers directory.

	* [misc/printdrv.c] [graphics/*/*] [include/win16drv.h]
        New files for printer support. 

Fri Aug 16 12:33:00 1996  Bruce Milner <Bruce.Milner@genetics.utah.edu>

	* [controls/scroll.c]
	Added SetScrollInfo32 and GetScrollInfo32.  These just call existing
	code. There are a few options in which I'm probably the wrong person
	for the job (page size and disable bar). There are comments in the
	code as to what they should do.

	* [objects/gdiobj.c] [objects/font.c] [include/font.h]
	Added 32 bit version of FONT_GetObject.
diff --git a/controls/menu.c b/controls/menu.c
index 7ac8c35..bc1a6ac 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -751,11 +751,13 @@
  *
  * Display a popup menu.
  */
-static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, int x, int y)
+static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, int x, int y, 
+						        int xanchor, int yanchor)
 {
     POPUPMENU 	*menu;
     WND 	*wndPtr = NULL;
     BOOL	 skip_init = 0;
+    UINT	 width, height;
 
     if (!(menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu ))) return FALSE;
     if (menu->FocusedItem != NO_SELECTED_ITEM)
@@ -767,6 +769,31 @@
 		 MAKELONG( id, (menu->wFlags & MF_SYSMENU) ? 1 : 0 ));
     MENU_PopupMenuCalcSize( menu, hwndOwner );
 
+    /* adjust popup menu pos so that it fits within the desktop */
+
+    width = menu->Width + 2*SYSMETRICS_CXBORDER;
+    height = menu->Height + 2*SYSMETRICS_CYBORDER; 
+
+    if( x + width > SYSMETRICS_CXSCREEN )
+    {
+	if( xanchor )
+            x -= width - xanchor;
+        if( x + width > SYSMETRICS_CXSCREEN)
+	    x = SYSMETRICS_CXSCREEN - width;
+    }
+    if( x < 0 )
+         x = 0;
+
+    if( y + height > SYSMETRICS_CYSCREEN )
+    { 
+	if( yanchor )
+	    y -= height + yanchor;
+	if( y + height > SYSMETRICS_CYSCREEN )
+	    y = SYSMETRICS_CYSCREEN - height;
+    }
+    if( y < 0 )
+	y = 0;
+
     wndPtr = WIN_FindWndPtr( hwndOwner );
     if (!wndPtr) return FALSE;
 
@@ -774,8 +801,7 @@
     {
 	pTopPWnd = WIN_FindWndPtr(CreateWindow16( POPUPMENU_CLASS_ATOM, NULL,
                                           WS_POPUP | WS_BORDER, x, y,
-                                          menu->Width + 2*SYSMETRICS_CXBORDER,
-                                          menu->Height + 2*SYSMETRICS_CYBORDER,
+                                          width, height,
                                           0, 0, wndPtr->hInstance,
                                           (LPVOID)(HMENU32)hmenu ));
 	if (!pTopPWnd) return FALSE;
@@ -787,8 +813,7 @@
 	/* create new window for the submenu */
 	HWND  hWnd = CreateWindow16( POPUPMENU_CLASS_ATOM, NULL,
                                    WS_POPUP | WS_BORDER, x, y,
-                                   menu->Width + 2*SYSMETRICS_CXBORDER,
-                                   menu->Height + 2*SYSMETRICS_CYBORDER,
+				   width, height,
                                    menu->hWnd, 0, wndPtr->hInstance,
                                    (LPVOID)(HMENU32)hmenu );
 	if( !hWnd ) return FALSE;
@@ -808,8 +833,7 @@
 
     wndPtr = WIN_FindWndPtr( menu->hWnd );
 
-    SetWindowPos(menu->hWnd, 0, x, y, menu->Width + 2*SYSMETRICS_CXBORDER, 
-				      menu->Height + 2*SYSMETRICS_CYBORDER,
+    SetWindowPos(menu->hWnd, 0, x, y, width, height,
 		  		      SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW);
       /* Display the window */
 
@@ -1164,7 +1188,8 @@
     if (menu->FocusedItem == SYSMENU_SELECTED)
     {
 	MENU_ShowPopup(hwndOwner, wndPtr->hSysMenu, 0, wndPtr->rectClient.left,
-		wndPtr->rectClient.top - menu->Height - 2*SYSMETRICS_CYBORDER);
+		wndPtr->rectClient.top - menu->Height - 2*SYSMETRICS_CYBORDER,
+		SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE );
 	if (selectFirst) MENU_SelectItemRel( hwndOwner, wndPtr->hSysMenu, ITEM_NEXT );
 	return wndPtr->hSysMenu;
     }
@@ -1176,13 +1201,16 @@
     {
 	MENU_ShowPopup( hwndOwner, (HMENU)item->item_id, menu->FocusedItem,
 		 wndPtr->rectWindow.left + item->rect.right-arrow_bitmap_width,
-		 wndPtr->rectWindow.top + item->rect.top );
+		 wndPtr->rectWindow.top + item->rect.top,
+		 item->rect.left - item->rect.right + 2*arrow_bitmap_width, 
+		 item->rect.top - item->rect.bottom );
     }
     else
     {
 	MENU_ShowPopup( hwndOwner, (HMENU)item->item_id, menu->FocusedItem,
 		        wndPtr->rectWindow.left + item->rect.left,
-		        wndPtr->rectWindow.top + item->rect.bottom );
+		        wndPtr->rectWindow.top + item->rect.bottom,
+			item->rect.right - item->rect.left, item->rect.bottom - item->rect.top );
     }
     if (selectFirst) MENU_SelectItemRel( hwndOwner, (HMENU)item->item_id, ITEM_NEXT );
     return (HMENU)item->item_id;
@@ -1451,7 +1479,8 @@
 	  else
 	  { 
 	     if( NC_GetSysPopupPos( wndPtr, &rect ) )
-	         MENU_ShowPopup( *hwndOwner, *hmenu, 0, rect.left, rect.bottom );
+	         MENU_ShowPopup( *hwndOwner, *hmenu, 0, rect.left, rect.bottom,
+		 SYSMETRICS_CXSIZE, SYSMETRICS_CYSIZE );
 
              if( !IsIconic( *hwndOwner ) )
              {
@@ -1837,7 +1866,7 @@
     BOOL ret = FALSE;
 
     HideCaret(0);
-    if (MENU_ShowPopup( hWnd, hMenu, 0, x, y )) 
+    if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 )) 
 	ret = MENU_TrackMenu( hMenu, wFlags, 0, 0, hWnd, lpRect );
     ShowCaret(0);
     return ret;
diff --git a/controls/scroll.c b/controls/scroll.c
index c54421c..4bc72d6 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -97,22 +97,22 @@
 /***********************************************************************
  *           SCROLL_GetPtrScrollInfo
  */
-static SCROLLINFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, int nBar )
+static SCROLLBAR_INFO *SCROLL_GetPtrScrollInfo( WND* wndPtr, int nBar )
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
 
     if (!wndPtr) return NULL;
     switch(nBar)
     {
-        case SB_HORZ: infoPtr = (SCROLLINFO *)wndPtr->pHScroll; break;
-        case SB_VERT: infoPtr = (SCROLLINFO *)wndPtr->pVScroll; break;
-        case SB_CTL:  infoPtr = (SCROLLINFO *)wndPtr->wExtra; break;
+        case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break;
+        case SB_VERT: infoPtr = (SCROLLBAR_INFO *)wndPtr->pVScroll; break;
+        case SB_CTL:  infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra; break;
         default:      return NULL;
     }
 
     if (!infoPtr)  /* Create the info structure if needed */
     {
-        if ((infoPtr = HeapAlloc( SystemHeap, 0, sizeof(SCROLLINFO) )))
+        if ((infoPtr = HeapAlloc( SystemHeap, 0, sizeof(SCROLLBAR_INFO) )))
         {
             infoPtr->MinVal = infoPtr->CurVal = 0;
             infoPtr->MaxVal = 100;
@@ -129,7 +129,7 @@
 /***********************************************************************
  *           SCROLL_GetScrollInfo
  */
-static SCROLLINFO *SCROLL_GetScrollInfo( HWND hwnd, int nBar )
+static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, int nBar )
 {
    WND *wndPtr = WIN_FindWndPtr( hwnd );
    return SCROLL_GetPtrScrollInfo( wndPtr, nBar );
@@ -195,7 +195,7 @@
     
     if ((pixels -= 3*SYSMETRICS_CXVSCROLL+1) > 0)
     {
-        SCROLLINFO *info = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
+        SCROLLBAR_INFO *info = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
         if ((info->flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH)
             *thumbPos = 0;
         else if (info->MinVal == info->MaxVal)
@@ -215,7 +215,7 @@
  * Compute the current scroll position based on the thumb position in pixels
  * from the top of the scroll-bar.
  */
-static UINT SCROLL_GetThumbVal( SCROLLINFO *infoPtr, RECT16 *rect,
+static UINT SCROLL_GetThumbVal( SCROLLBAR_INFO *infoPtr, RECT16 *rect,
                                 BOOL vertical, WORD pos )
 {
     int pixels = vertical ? rect->bottom-rect->top : rect->right-rect->left;
@@ -274,7 +274,7 @@
  *
  * Draw the scroll bar arrows.
  */
-static void SCROLL_DrawArrows( HDC hdc, SCROLLINFO *infoPtr, RECT16 *rect,
+static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr, RECT16 *rect,
                                WORD arrowSize, BOOL vertical,
                                BOOL top_pressed, BOOL bottom_pressed )
 {
@@ -451,7 +451,7 @@
     RECT16 rect;
     BOOL vertical;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
-    SCROLLINFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
+    SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
 
     if (!wndPtr || !infoPtr ||
         ((nBar == SB_VERT) && !(wndPtr->dwStyle & WS_VSCROLL)) ||
@@ -482,7 +482,7 @@
     BOOL vertical;
     HDC hdc;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
-    SCROLLINFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
+    SCROLLBAR_INFO *infoPtr = SCROLL_GetPtrScrollInfo( wndPtr, nBar );
 
     if (!wndPtr || !infoPtr ||
         ((nBar == SB_VERT) && !(wndPtr->dwStyle & WS_VSCROLL)) ||
@@ -552,7 +552,7 @@
     RECT16 rect;
     HDC hdc;
 
-    SCROLLINFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
+    SCROLLBAR_INFO *infoPtr = SCROLL_GetScrollInfo( hwnd, nBar );
     if (!infoPtr) return;
     if ((trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN)) return;
 
@@ -827,7 +827,7 @@
  */
 int SetScrollPos( HWND hwnd, int nBar, int nPos, BOOL bRedraw )
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
     INT oldPos;
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
@@ -849,7 +849,7 @@
  */
 int GetScrollPos( HWND hwnd, int nBar )
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return 0;
     return infoPtr->CurVal;
@@ -861,7 +861,7 @@
  */
 void SetScrollRange(HWND hwnd, int nBar, int MinVal, int MaxVal, BOOL bRedraw)
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return;
 
@@ -889,7 +889,7 @@
 DWORD SCROLL_SetNCSbState(WND* wndPtr, int vMin, int vMax, int vPos,
 				       int hMin, int hMax, int hPos)
 {
-  SCROLLINFO  *infoPtr = SCROLL_GetPtrScrollInfo(wndPtr, SB_VERT);
+  SCROLLBAR_INFO  *infoPtr = SCROLL_GetPtrScrollInfo(wndPtr, SB_VERT);
  
   wndPtr->dwStyle |= (WS_VSCROLL | WS_HSCROLL);
 
@@ -919,7 +919,7 @@
  */
 void GetScrollRange(HWND hwnd, int nBar, LPINT16 lpMin, LPINT16 lpMax)
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return;
     if (lpMin) *lpMin = infoPtr->MinVal;
@@ -997,7 +997,7 @@
  */
 BOOL EnableScrollBar( HWND hwnd, UINT nBar, UINT flags )
 {
-    SCROLLINFO *infoPtr;
+    SCROLLBAR_INFO *infoPtr;
     HDC hdc;
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
@@ -1012,3 +1012,59 @@
     ReleaseDC( hwnd, hdc );
     return TRUE;
 }
+
+
+/*************************************************************************
+ *           SetScrollInfo32   (USER32.500)
+ */
+INT32 SetScrollInfo32( HWND32 hwnd, INT32 nBar, LPSCROLLINFO32 lpsi,
+                       BOOL32 bRedraw )
+{
+    SCROLLBAR_INFO *infoPtr;
+
+    if (!(infoPtr = SCROLL_GetScrollInfo(hwnd, nBar))) return 0;
+
+    if (lpsi->fMask & SIF_PAGE) {
+	/* fixme: The page size isn't used in the current
+	 * scrolling code - it's new for win32
+	 */
+	infoPtr->Page = lpsi->nPage;
+    }
+    if (lpsi->fMask & SIF_POS)
+        SetScrollPos(hwnd, nBar, lpsi->nPos, FALSE);
+    if (lpsi->fMask & SIF_RANGE)
+        SetScrollRange(hwnd, nBar, lpsi->nMin, lpsi->nMax, FALSE);
+    if (lpsi->fMask & SIF_DISABLENOSCROLL) {
+	/* fixme: Disable scroll bar if the new parameters make
+	 * the scroll bar unneeded
+	 */
+	dprintf_scroll(stddeb, "SetScrollInfo: SIF_DISABLENOSCROLL not supported yet\n");
+    }
+
+    if (bRedraw) SCROLL_RefreshScrollBar(hwnd, nBar);
+
+    /* return current thumb position */
+    return (infoPtr->CurVal);
+}
+
+
+/*************************************************************************
+ *           GetScrollInfo32   (USER32.283)
+ */
+BOOL32 GetScrollInfo32( HWND32 hwnd, INT32 nBar, LPSCROLLINFO32 lpsi )
+{
+    SCROLLBAR_INFO *infoPtr;
+
+    if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE;
+
+    if (lpsi->fMask & SIF_PAGE) lpsi->nPage = infoPtr->Page;
+    if (lpsi->fMask & SIF_POS) lpsi->nPos = infoPtr->CurVal;
+    if (lpsi->fMask & SIF_TRACKPOS)
+        lpsi->nTrackPos = hwndTracking ? uTrackingPos : 0;
+    if (lpsi->fMask & SIF_RANGE)
+    {
+	lpsi->nMin = infoPtr->MinVal;
+	lpsi->nMax = infoPtr->MaxVal;
+    }
+    return TRUE;
+}
diff --git a/controls/widgets.c b/controls/widgets.c
index 236dfe3..7495665 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -30,7 +30,7 @@
     { CS_GLOBALCLASS | CS_PARENTDC,
        sizeof(STATICINFO), 0, "StaticWndProc", "STATIC" },
     { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
-      sizeof(SCROLLINFO), 0, "ScrollBarWndProc", "SCROLLBAR" },
+      sizeof(SCROLLBAR_INFO), 0, "ScrollBarWndProc", "SCROLLBAR" },
     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
       8, 0, "ListBoxWndProc", "LISTBOX" },
     { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,