diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index 4e27232..c2f2429 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -29,6 +29,9 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
+/* for GET_X_LPARAM and GET_Y_LPARAM */
+#include <windowsx.h>
+
 #include <grobjs.h>
 #include <grdevice.h>
 #ifdef SWIZZLE
@@ -109,6 +112,12 @@
 
   static ATOM  ourAtom;
 
+  /* set to true while the window is being resized  */
+  static BOOL     isWindowResizing  = FALSE;
+  
+  /* direction in which the window is being resized */
+  static LRESULT  resizeDirection   = HTNOWHERE;
+
   typedef struct grWin32SurfaceRec_
   {
     grSurface     root;
@@ -530,6 +539,122 @@ LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
 
     switch( mess )
     {
+    case WM_NCHITTEST:
+    {
+      LRESULT result;
+
+
+      result = DefWindowProcA( handle, mess, wParam, lParam );
+      
+      switch (result) 
+      {
+      case HTBOTTOM:
+      case HTBOTTOMLEFT:
+      case HTBOTTOMRIGHT:
+      case HTLEFT:
+      case HTRIGHT:
+      case HTTOP:
+      case HTTOPLEFT:
+      case HTTOPRIGHT:
+        resizeDirection = result;
+        break;
+      default:
+        resizeDirection = HTNOWHERE;
+      }
+
+      return result;
+    }
+    case WM_MOUSEMOVE:
+    {
+      if ( isWindowResizing == TRUE )
+      {
+        /* the window rect dosen't contain top border/titlebar so we  */
+        /* have to get the client rect and take the difference to get */
+        /* the top border                                             */
+        RECT windowRect;
+        RECT clientRect;
+
+        POINT diff;
+        POINT mousePos;
+
+
+        GetWindowRect( handle, &windowRect );
+        GetClientRect( handle, &clientRect );
+
+        diff.x = ( windowRect.right - windowRect.left ) - clientRect.right;
+        diff.y = ( windowRect.bottom - windowRect.top ) - clientRect.bottom;
+
+        GetCursorPos( &mousePos );
+        /* to get cursor pos relative to the window */
+        ScreenToClient( handle, &mousePos );
+
+        /* resize the window accordingly            */
+        switch ( resizeDirection ) {
+        case HTBOTTOM:
+        {
+          SetWindowPos( handle, HWND_TOP, windowRect.left, windowRect.top,
+                        windowRect.right - windowRect.left, mousePos.y + diff.y, 0u );
+          break;
+        }
+        case HTBOTTOMLEFT:
+        {
+          SetWindowPos( handle, HWND_TOP, windowRect.left + mousePos.x, windowRect.top,
+                        windowRect.right - windowRect.left - mousePos.x, mousePos.y + diff.y, 0u );
+          break;
+        }
+        case HTBOTTOMRIGHT:
+        {
+          SetWindowPos( handle, HWND_TOP, windowRect.left, windowRect.top,
+                        mousePos.x + diff.x, mousePos.y + diff.y, 0u );
+          break;
+        }
+        case HTLEFT:
+          SetWindowPos( handle, HWND_TOP, windowRect.left + mousePos.x, windowRect.top, 
+                        windowRect.right - windowRect.left - mousePos.x, windowRect.bottom - windowRect.top, 0u );
+          break;
+        case HTRIGHT:
+          SetWindowPos( handle, HWND_TOP, windowRect.left, windowRect.top,
+                        mousePos.x + diff.x, windowRect.bottom - windowRect.top, 0u );
+          break;
+        case HTTOP:
+          SetWindowPos( handle, HWND_TOP, windowRect.left, windowRect.top + mousePos.y + diff.y,
+                        windowRect.right - windowRect.left, windowRect.bottom - windowRect.top - mousePos.y - diff.y, 0u );
+          break;
+        case HTTOPLEFT:
+          SetWindowPos( handle, HWND_TOP, windowRect.left + mousePos.x, windowRect.top + mousePos.y + diff.y,
+                        windowRect.right - windowRect.left - mousePos.x, windowRect.bottom - windowRect.top - mousePos.y - diff.y, 0u );
+          break;
+        case HTTOPRIGHT:
+          SetWindowPos( handle, HWND_TOP, windowRect.left, windowRect.top + mousePos.y + diff.y,
+                        mousePos.x + diff.x, windowRect.bottom - windowRect.top - mousePos.y - diff.y, 0u );
+          break;
+        default:
+          break;
+        }
+      }
+
+      break;
+    }
+    case WM_LBUTTONUP:
+      ReleaseCapture();
+      isWindowResizing = FALSE;
+      break;
+    case WM_SYSCOMMAND:
+    {
+      switch ( wParam & 0xFFF0 ) {
+      case SC_SIZE:
+      {
+        /* capture mouse so as to receive WM_MOUSEMOVE if mouse */
+        /* goes outside the window                              */
+        SetCapture( handle );
+        isWindowResizing = TRUE;
+        break;
+      }
+      default:
+        return DefWindowProc( handle, mess, wParam, lParam ); 
+      }
+      return 0;
+    }
     case WM_DESTROY:
         /* warn the main thread to quit if it didn't know */
       surface->ourevent.type  = gr_event_key;
