Release 940815

Tue Aug  9 23:58:29 MET DST 1994	<erik@hacktic.nl>

	* [misc/file.c]
	OpenFile(): Completly rewritten.

	* [miscemu/int21.c]
	CreateFile(): Fixed wrong mode in call to open.
	OpenExistingFile(): Implemented file sharing.
	FindNext(): Fixed.
	CreateNewFile(): Fixed wrong mode in call to open.
	fLock(): Added to handle record locking.
	GetFileAttribute(): Added.
	As a result, AH = 0x5c, 0x09, and 0x0b were changed.

	* [miscemu/int2f.c]
	AH = 0x10: SHARE installation check
 
	* [loader/resource.c]
	AccessResource(): Fixed. A new file descriptor will be returned by
	every call to AccessResource().

	* [windows/utility.c]
	wvsprintf(): Fixed.

	* [controls/menu.c]
	FindMenuItem(): Fixed (handling for nPos == -1 added).	

	* [windows/win.c]
	CreateWindowEx(): Added call to WINPOS_GetMinMaxInfo.

	* [Configure]
	Added two options for a processor emulator that might be
	plugged in later..

	* [loader/task.c] [include/toolhelp.h] [if1632/toolhelp.spec]
	CreateNewTask() stores real modulename instead of 'TASKxxxx'.
	Added TaskFirst(), TaskNext(), TaskFindHandle().

	* [memory/global.c]
	Added stub for MemManInfo().

	* [objects/text.c]
	Added stub for GetTabbedTextExt().

	* [miscemu/*]
	Changed all references to registers. Please don't access
 	the context structure.
	fix for GetSystemTime() by <jspeter@birch.ee.vt.edu> added.

	* [misc/lstr.c]
	Fixed bug in AnsiUpper() & AnsiLower().

	* [misc/winsocket.c]
	bugfix in getsockopt()/setsockopt(): winsock uses different values
	than unix.

	* [objects/dib.c]
	Added DIB_SetImageBits_RLE[48] to support compressed bitmaps.

Mon Aug  8 21:12:33 1994  David Metcalfe <david@prism.demon.co.uk>

	* [controls/edit.c]
	Added support for WM_COPY, WM_CUT and WM_PASTE messages.

	* [windows/dialog.c] [windows/defdlg.c] [include/dialog.h]
	Modified dialog code to create new heap for edit controls
	unless DS_LOCALEDIT style is set.

Thu Aug  4 18:50:56 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [controls/button.c] [controls/edit.c] [controls/static.c]
	Removed unneeded GlobalUnlock() calls.

	* [controls/menu.c] [include/menu.h]
	Lots of changes, fixed a lot of old bugs and introduced a lot of
	new ones :-)
	- Changed message loop to use MSG_GetInternalMessage().
	- Fixed a bug that caused the main window to lose activation when
	  displaying a menu.
	- Correctly send initialisation messages (WM_INITMENUPOPUP).
	- Implemented EndMenu() and LookupMenuHandle().
	- Changed internal structures to be as compatible as possible with
	  MS-Windows.
	- Allocated everything on the USER heap instead of the global heap.
	- Prefixed all internal function names with MENU_ and declared
	  them static.
	- Moved "About Wine..." handling to NC_HandleSysCommand().
	- Multi-line menus should now work correctly.

	* [loader/resource.c] [objects/bitmap.c]
	Added the possibility to create OEM bitmaps directly as X bitmaps.

	* [objects/dcvalues.c] [windows/dc.c]
	Fixed GetDCOrg() to return screen coordinates.

	* [windows/message.c]
	Fixed double-click checks when the message is not removed from the
	queue.
	Fixed MSG_GetInternalMessage() to send WM_ENTERIDLE messages.

	* [windows/nonclient.c]
	Bug fix in system menu hit-test calculation.
	A few changes for new menu functions.

Thu Aug 11 17:51:02 1994  Thomas Sandford <t.d.g.sandford@bradford.ac.uk>

        * [controls/edit.c]
        Bug fix in Edit_NCCreateMessage
        es->textlen was being used before being set

        * [controls/menu.c]
        Bug fix in MENU_DrawMenuItem
        don't try to write text if NULL pointer passed
diff --git a/windows/nonclient.c b/windows/nonclient.c
index c364b02..2bb188e 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -12,7 +12,6 @@
 #include "sysmetrics.h"
 #include "user.h"
 #include "scroll.h"
-#include "menu.h"
 #include "syscolor.h"
 
 static HBITMAP hbitmapClose = 0;
@@ -24,11 +23,19 @@
 static HBITMAP hbitmapRestore = 0;
 static HBITMAP hbitmapRestoreD = 0;
 
+#define SC_ABOUTWINE    	(SC_SCREENSAVE+1)
+extern HINSTANCE hSysRes;
+extern BOOL AboutWine_Proc( HWND hDlg, WORD msg, WORD wParam, LONG lParam );
+
 extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
 			    POINT *minTrack, POINT *maxTrack );  /* winpos.c */
 extern void CURSOR_SetWinCursor( HWND hwnd, HCURSOR hcursor );   /* cursor.c */
 extern WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth,
 				   int orgX, int orgY );         /* menu.c */
+extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt );       /* menu.c */
+extern void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam );      /* menu.c */
+extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
+			      HMENU hmenu, BOOL suppress_draw ); /* menu.c */
 
 
   /* Some useful macros */
@@ -70,8 +77,8 @@
     }
 
     if ((style & WS_CAPTION) == WS_CAPTION)
-	rect->top -= SYSMETRICS_CYCAPTION - 1;
-    if (menu) rect->top -= SYSMETRICS_CYMENU + 1;
+	rect->top -= SYSMETRICS_CYCAPTION - SYSMETRICS_CYBORDER;
+    if (menu) rect->top -= SYSMETRICS_CYMENU + SYSMETRICS_CYBORDER;
 
     if (style & WS_VSCROLL) rect->right  += SYSMETRICS_CXVSCROLL;
     if (style & WS_HSCROLL) rect->bottom += SYSMETRICS_CYHSCROLL;
@@ -237,8 +244,9 @@
 	if (!PtInRect( &rect, pt ))
 	{
 	      /* Check system menu */
-	    if ((wndPtr->dwStyle & WS_SYSMENU) && (pt.x <= SYSMETRICS_CXSIZE))
-		return HTSYSMENU;
+	    if (wndPtr->dwStyle & WS_SYSMENU)
+		rect.left += SYSMETRICS_CXSIZE;
+	    if (pt.x <= rect.left) return HTSYSMENU;
 	      /* Check maximize box */
 	    if (wndPtr->dwStyle & WS_MAXIMIZEBOX)
 		rect.right -= SYSMETRICS_CXSIZE + 1;
@@ -311,7 +319,7 @@
 /***********************************************************************
  *           NC_DrawSysButton
  */
-static void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
+void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down )
 {
     RECT rect;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
@@ -611,19 +619,17 @@
     if ((wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION)
     {
 	RECT r = rect;
-	rect.top += SYSMETRICS_CYSIZE + 1;
-	r.bottom = rect.top - 1;
+	r.bottom = rect.top + SYSMETRICS_CYSIZE;
+	rect.top += SYSMETRICS_CYSIZE + SYSMETRICS_CYBORDER;
 	NC_DrawCaption( hdc, &r, hwnd, wndPtr->dwStyle, active );
     }
 
     if (HAS_MENU(wndPtr))
     {
-	LPPOPUPMENU lpMenu = (LPPOPUPMENU) GlobalLock( wndPtr->wIDmenu );
 	RECT r = rect;
-	r.bottom = rect.top + lpMenu->Height;
-	rect.top += lpMenu->Height;
-	StdDrawMenuBar( hdc, &r, lpMenu, suppress_menupaint );
-	GlobalUnlock( wndPtr->wIDmenu );
+	r.bottom = rect.top + SYSMETRICS_CYMENU;  /* default height */
+	rect.top += MENU_DrawMenuBar( hdc, &r, (HMENU)wndPtr->wIDmenu,
+				      suppress_menupaint );
     }
 
     if (wndPtr->dwStyle & (WS_VSCROLL | WS_HSCROLL)) {
@@ -1111,27 +1117,33 @@
     ReleaseCapture();
 }
 
-
 /***********************************************************************
- *           NC_TrackMouseMenuBar
+ *           NC_TrackSysMenu
  *
- * Track a mouse events for the MenuBar.
+ * Track a mouse button press on the system menu.
  */
-static void NC_TrackMouseMenuBar( HWND hwnd, WORD wParam, POINT pt )
+static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt )
 {
-    WND		*wndPtr;
-    LPPOPUPMENU lppop;
-    MSG 	msg;
-    wndPtr = WIN_FindWndPtr(hwnd);
-    lppop = (LPPOPUPMENU)GlobalLock(wndPtr->wIDmenu);
-#ifdef DEBUG_MENU
-    printf("NC_TrackMouseMenuBar // wndPtr=%08X lppop=%08X !\n", wndPtr, lppop);
-#endif
-    ScreenToClient(hwnd, &pt);
-    pt.y += lppop->rect.bottom;
-    SetCapture(hwnd);
-    MenuButtonDown(hwnd, lppop, pt.x, pt.y);
-    GlobalUnlock(wndPtr->wIDmenu);
+    RECT rect;
+    WND *wndPtr = WIN_FindWndPtr( hwnd );
+
+    if (!(wndPtr->dwStyle & WS_SYSMENU)) return;
+      /* If window has a menu, track the menu bar normally */
+    if (HAS_MENU(wndPtr)) MENU_TrackMouseMenuBar( hwnd, pt );
+    else
+    {
+	  /* Otherwise track the system menu like a normal popup menu */
+	NC_GetInsideRect( hwnd, &rect );
+	OffsetRect( &rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
+	if (wndPtr->dwStyle & WS_CHILD)
+	    ClientToScreen( wndPtr->hwndParent, (POINT *)&rect );
+	rect.right = rect.left + SYSMETRICS_CXSIZE;
+	rect.bottom = rect.top + SYSMETRICS_CYSIZE;
+	NC_DrawSysButton( hwnd, hdc, TRUE );
+	TrackPopupMenu( wndPtr->hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
+		        rect.left, rect.bottom, 0, hwnd, &rect );
+	NC_DrawSysButton( hwnd, hdc, FALSE );
+    }
 }
 
 
@@ -1151,8 +1163,7 @@
 	break;
 
     case HTSYSMENU:
-	NC_DrawSysButton( hwnd, hdc, TRUE );
-	NC_TrackSysMenu(hwnd);
+	NC_TrackSysMenu( hwnd, hdc, MAKEPOINT(lParam) );
 	break;
 
     case HTMENU:
@@ -1263,22 +1274,28 @@
 	break;
 
     case SC_MOUSEMENU:
-	NC_TrackMouseMenuBar( hwnd, wParam, pt );
+	MENU_TrackMouseMenuBar( hwnd, pt );
 	break;
 
     case SC_KEYMENU:
-/*	NC_KeyMenuBar( hwnd, wParam, pt ); */
+	MENU_TrackKbdMenuBar( hwnd, wParam );
 	break;
 	
     case SC_ARRANGE:
 	break;
 
     case SC_TASKLIST:
-    case SC_SCREENSAVE:
+	/* WinExec( "taskman.exe", SW_SHOWNORMAL ); */
+	break;
+
     case SC_HOTKEY:
 	break;
+
+    case SC_SCREENSAVE:
+	if (wParam == SC_ABOUTWINE)
+	    DialogBox( hSysRes, MAKEINTRESOURCE(2), 
+		       hwnd, (FARPROC)AboutWine_Proc );
+	break;
     }
     return 0;
 }
-
-