ANSI C fixes.
Removed warnings.
Made the include files self-sufficient.
Some Solaris fixes.

diff --git a/windows/caret.c b/windows/caret.c
index 35b1245..90fa950 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -5,10 +5,12 @@
  * Copyright 1996 Frans van Dorsselaer
  */
 
-#include "winuser.h"
-#include "module.h"
-#include "debug.h"
 #include "wine/wingdi16.h"
+#include "wine/winuser16.h"
+#include "module.h"
+#include "win.h"
+#include "winuser.h"
+#include "debug.h"
 
 DEFAULT_DEBUG_CHANNEL(caret)
 
diff --git a/windows/display.c b/windows/display.c
index ce3a09f..a864032 100644
--- a/windows/display.c
+++ b/windows/display.c
@@ -44,7 +44,7 @@
 /***********************************************************************
  *           DISPLAY_CheckCursor                  (DISPLAY.104)
  */
-VOID WINAPI DISPLAY_CheckCursor()
+VOID WINAPI DISPLAY_CheckCursor( void )
 {
     TRACE( cursor, "stub\n" );
 }
diff --git a/windows/driver.c b/windows/driver.c
index 41dfba8..e9f7d06 100644
--- a/windows/driver.c
+++ b/windows/driver.c
@@ -132,7 +132,7 @@
  * -1 : ko, unknown message
  * -2 : ko, memory problem
  */
-int	DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
+static int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
 {
     int	ret = -1;
     
@@ -217,7 +217,7 @@
  * -1 : ko
  * -2 : ko, memory problem
  */
-int	DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
+static int DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
 {
     int	ret = -1;
     
@@ -284,7 +284,7 @@
  * -1 : ko, unknown message
  * -2 : ko, memory problem
  */
-int	DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
+static int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
 {
     int	ret = -1;
     
@@ -393,7 +393,7 @@
  * -1 : ko
  * -2 : ko, memory problem
  */
-int	DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
+static int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
 {
     int	ret = -1;
     
diff --git a/windows/mdi.c b/windows/mdi.c
index dc603bc..d3fae2d 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -23,6 +23,7 @@
 #include "user.h"
 #include "menu.h"
 #include "resource.h"
+#include "scroll.h"
 #include "struct32.h"
 #include "tweak.h"
 #include "debug.h"
@@ -34,8 +35,6 @@
 static HBITMAP16 hBmpClose   = 0;
 static HBITMAP16 hBmpRestore = 0;
 
-INT SCROLL_SetNCSbState(WND*,int,int,int,int,int,int);
-
 /* ----------------- declarations ----------------- */
 static void MDI_UpdateFrameText(WND *, HWND, BOOL, LPCSTR);
 static BOOL MDI_AugmentFrameMenu(MDICLIENTINFO*, WND *, HWND);
diff --git a/windows/message.c b/windows/message.c
index 6ca48dd..c956043 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -49,7 +49,7 @@
 /***********************************************************************
  *           MSG_CheckFilter
  */
-BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
+static BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
 {
    if( first || last )
        return (uMsg >= first && uMsg <= last);
@@ -1553,7 +1553,7 @@
  * return values: 0 if timeout occurs
  *                1 otherwise
  */
-LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
+static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
                          LPARAM lParam, DWORD timeout, WORD flags,
                          LRESULT *pRes)
 {
diff --git a/windows/msgbox.c b/windows/msgbox.c
index 21a9207..ec5ff2b 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -5,6 +5,8 @@
  */
 
 #include <string.h>
+
+#include "wine/winbase16.h"
 #include "wine/winuser16.h"
 #include "dlgs.h"
 #include "heap.h"
diff --git a/windows/multimon.c b/windows/multimon.c
index 5dc3987..e8b407a 100644
--- a/windows/multimon.c
+++ b/windows/multimon.c
@@ -21,7 +21,7 @@
 /***********************************************************************
  *              MONITOR_GetMonitor
  */
-MONITOR *MONITOR_GetMonitor(HMONITOR hMonitor)
+static MONITOR *MONITOR_GetMonitor(HMONITOR hMonitor)
 {
   if(hMonitor == xPRIMARY_MONITOR)
     {
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 16015e5..f382f04 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -636,7 +636,7 @@
  * Handle a WM_NCHITTEST message. Called from NC_HandleNcHitTest().
  */
 
-LONG NC_DoNCHitTest (WND *wndPtr, POINT16 pt )
+static LONG NC_DoNCHitTest (WND *wndPtr, POINT16 pt )
 {
     RECT16 rect;
 
@@ -771,7 +771,7 @@
  * FIXME:  Just a modified copy of the Win 3.1 version.
  */
 
-LONG
+static LONG
 NC_DoNCHitTest95 (WND *wndPtr, POINT16 pt )
 {
     RECT16 rect;
@@ -1070,7 +1070,7 @@
  *
  *****************************************************************************/
 
-void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down)
+static void NC_DrawCloseButton95 (HWND hwnd, HDC hdc, BOOL down)
 {
     RECT rect;
     HDC hdcMem;
@@ -1556,7 +1556,7 @@
  *
  * Paint the non-client area. clip is currently unused.
  */
-void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
+static void NC_DoNCPaint( WND* wndPtr, HRGN clip, BOOL suppress_menupaint )
 {
     HDC hdc;
     RECT rect;
@@ -1667,7 +1667,7 @@
  *
  *****************************************************************************/
 
-void  NC_DoNCPaint95(
+static void  NC_DoNCPaint95(
     WND  *wndPtr,
     HRGN  clip,
     BOOL  suppress_menupaint )
diff --git a/windows/painting.c b/windows/painting.c
index db20ef5..25d146f 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -380,10 +380,14 @@
      */
 
     BOOL bHadOne =  wndPtr->hrgnUpdate && hRgn;
-    RECT r = {0, 0, wndPtr->rectWindow.right - wndPtr->rectWindow.left,
-		    wndPtr->rectWindow.bottom - wndPtr->rectWindow.top };
     BOOL bChildren =  ( wndPtr->child && !(flags & RDW_NOCHILDREN) && !(wndPtr->dwStyle & WS_MINIMIZE) 
 			&& ((flags & RDW_ALLCHILDREN) || !(wndPtr->dwStyle & WS_CLIPCHILDREN)) );
+    RECT r;
+
+    r.left = 0;
+    r.top = 0;
+    r.right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
+    r.bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
 
     TRACE_(win)("\thwnd %04x [%04x] -> hrgn [%04x], flags [%04x]\n", wndPtr->hwndSelf, wndPtr->hrgnUpdate, hRgn, flags );
 
@@ -411,8 +415,8 @@
 			    }
 			}
 			break;
-
 		case 1:	/* already an entire window */
+		        break;
 	    }
 	}
 	else if( hRgn == 1 )
@@ -474,9 +478,11 @@
 	if( hRgn > 1 && bChildren )
 	{
             WND* wnd = wndPtr->child;
-            POINT ptClient = { wndPtr->rectClient.left - wndPtr->rectWindow.left,
-                               wndPtr->rectClient.top - wndPtr->rectWindow.top };
 	    POINT ptTotal, prevOrigin = {0,0};
+            POINT ptClient;
+
+            ptClient.x = wndPtr->rectClient.left - wndPtr->rectWindow.left;
+            ptClient.y = wndPtr->rectClient.top - wndPtr->rectWindow.top;
 
             for( ptTotal.x = ptTotal.y = 0; wnd; wnd = wnd->next )
             {
diff --git a/windows/queue.c b/windows/queue.c
index 662aa6f..7c8afc6 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -488,7 +488,7 @@
  * 
  * Try to reply to all pending sent messages on exit.
  */
-void QUEUE_FlushMessages( MESSAGEQUEUE *queue )
+static void QUEUE_FlushMessages( MESSAGEQUEUE *queue )
 {
     SMSG *smsg;
     MESSAGEQUEUE *senderQ = 0;
diff --git a/windows/scroll.c b/windows/scroll.c
index ef817a4..0bf8adf 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -9,6 +9,7 @@
 
 #include <stdlib.h>
 
+#include "wine/winuser16.h"
 #include "winuser.h"
 #include "dc.h"
 #include "win.h"
diff --git a/windows/syscolor.c b/windows/syscolor.c
index f3f3896..210d8bd 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -9,6 +9,10 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+
+#include "wine/winbase16.h"
+#include "wine/winuser16.h"
+#include "sysmetrics.h"
 #include "winbase.h"
 #include "winuser.h"
 #include "debug.h"
diff --git a/windows/sysmetrics.c b/windows/sysmetrics.c
index d8d6006..fb6d9b0 100644
--- a/windows/sysmetrics.c
+++ b/windows/sysmetrics.c
@@ -12,6 +12,7 @@
 #include "winuser.h"
 #include "monitor.h"
 #include "options.h"
+#include "sysmetrics.h"
 #include "tweak.h"
 
 static short sysMetrics[SM_CMETRICS+1];
diff --git a/windows/timer.c b/windows/timer.c
index 34fa262..4250b0b 100644
--- a/windows/timer.c
+++ b/windows/timer.c
@@ -4,11 +4,13 @@
  * Copyright 1993 Alexandre Julliard
  */
 
+#include "wine/winuser16.h"
 #include "winuser.h"
 #include "queue.h"
 #include "task.h"
 #include "winproc.h"
 #include "services.h"
+#include "message.h"
 #include "debug.h"
 
 DEFAULT_DEBUG_CHANNEL(timer)
diff --git a/windows/winproc.c b/windows/winproc.c
index a6e1e79..fc3e698 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -402,7 +402,7 @@
  *
  * Return TRUE if the lparam is a string
  */
-BOOL WINPROC_TestCBForStr ( HWND hwnd )
+static BOOL WINPROC_TestCBForStr ( HWND hwnd )
 {
     BOOL retvalue;
     WND * wnd = WIN_FindWndPtr(hwnd);
@@ -416,7 +416,7 @@
  *
  * Return TRUE if the lparam is a string
  */
-BOOL WINPROC_TestLBForStr ( HWND hwnd )
+static BOOL WINPROC_TestLBForStr ( HWND hwnd )
 {
     BOOL retvalue;
     WND * wnd = WIN_FindWndPtr(hwnd); 
diff --git a/windows/x11drv/keyboard.c b/windows/x11drv/keyboard.c
index 05f5554..faa5d43 100644
--- a/windows/x11drv/keyboard.c
+++ b/windows/x11drv/keyboard.c
@@ -380,7 +380,7 @@
  * Convention : called with vkey only VK_NUMLOCK or VK_CAPITAL
  *
  */
-void KEYBOARD_GenerateMsg( WORD vkey, WORD scan, int Evtype, INT event_x, INT event_y,
+static void KEYBOARD_GenerateMsg( WORD vkey, WORD scan, int Evtype, INT event_x, INT event_y,
                            DWORD event_time )
 {
   BOOL * State = (vkey==VK_NUMLOCK? &NumState : &CapsState);
@@ -429,7 +429,7 @@
  * Updates internal state for <vkey>, depending on key <state> under X
  *
  */
-void KEYBOARD_UpdateOneState ( int vkey, int state )
+static void KEYBOARD_UpdateOneState ( int vkey, int state )
 {
     /* Do something if internal table state != X state for keycode */
     if (((pKeyStateTable[vkey] & 0x80)!=0) != state)
@@ -592,7 +592,7 @@
  *  This routine walks through the defined keyboard layouts and selects
  *  whichever matches most closely.
  */
-void
+static void
 X11DRV_KEYBOARD_DetectLayout (void)
 {
   unsigned current, match, mismatch, seq;