*** C:/Program Files (x86)/Borland/BDS/4.0/source/Win32/rtl/win/Windows.pas.original	Mon Nov 14 19:00:00 2005
--- C:/Program Files (x86)/Borland/BDS/4.0/source/Win32/rtl/win/Windows.pas	Fri Nov 10 11:18:42 2006
***************
*** 21236,21242 ****
  {$EXTERNALSYM MsgWaitForMultipleObjects}
  function MsgWaitForMultipleObjects(nCount: DWORD; var pHandles;
    fWaitAll: BOOL; dwMilliseconds, dwWakeMask: DWORD): DWORD; stdcall;
! {$EXTERNALSYM MsgWaitForMultipleObjectsEx}
  function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles;
    dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD; stdcall;
  
--- 21236,21242 ----
  {$EXTERNALSYM MsgWaitForMultipleObjects}
  function MsgWaitForMultipleObjects(nCount: DWORD; var pHandles;
    fWaitAll: BOOL; dwMilliseconds, dwWakeMask: DWORD): DWORD; stdcall;
! {.$EXTERNALSYM MsgWaitForMultipleObjectsEx}
  function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles;
    dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD; stdcall;
  
***************
*** 30386,30392 ****
  function GetWindowExtEx; external gdi32 name 'GetWindowExtEx';
  function GetWindowOrgEx; external gdi32 name 'GetWindowOrgEx';
  function GetWorldTransform; external gdi32 name 'GetWorldTransform';
! function GradientFill; external msimg32 name 'GradientFill';
  function IntersectClipRect; external gdi32 name 'IntersectClipRect';
  function InvertRgn; external gdi32 name 'InvertRgn';
  function LPtoDP; external gdi32 name 'LPtoDP';
--- 30386,30393 ----
  function GetWindowExtEx; external gdi32 name 'GetWindowExtEx';
  function GetWindowOrgEx; external gdi32 name 'GetWindowOrgEx';
  function GetWorldTransform; external gdi32 name 'GetWorldTransform';
! // Removed 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
! // function GradientFill; external msimg32 name 'GradientFill';
  function IntersectClipRect; external gdi32 name 'IntersectClipRect';
  function InvertRgn; external gdi32 name 'InvertRgn';
  function LPtoDP; external gdi32 name 'LPtoDP';
***************
*** 31013,31019 ****
  function ModifyMenuW; external user32 name 'ModifyMenuW';
  function MoveWindow; external user32 name 'MoveWindow';
  function MsgWaitForMultipleObjects; external user32 name 'MsgWaitForMultipleObjects';
! function MsgWaitForMultipleObjectsEx; external user32 name 'MsgWaitForMultipleObjectsEx';
  procedure NotifyWinEvent; external user32 name 'NotifyWinEvent';
  function OemKeyScan; external user32 name 'OemKeyScan';
  function OemToAnsi; external user32 name 'OemToCharA';
--- 31014,31021 ----
  function ModifyMenuW; external user32 name 'ModifyMenuW';
  function MoveWindow; external user32 name 'MoveWindow';
  function MsgWaitForMultipleObjects; external user32 name 'MsgWaitForMultipleObjects';
! // Removed 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
! // function MsgWaitForMultipleObjectsEx; external user32 name 'MsgWaitForMultipleObjectsEx';
  procedure NotifyWinEvent; external user32 name 'NotifyWinEvent';
  function OemKeyScan; external user32 name 'OemKeyScan';
  function OemToAnsi; external user32 name 'OemToCharA';
***************
*** 31833,31840 ****
--- 31835,31903 ----
      Result := _TranslateCharsetInfo(lpSrc, lpCs, dwFlags);
  end;
  
+ // Added 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
+ type TFuncMsgWaitForMultipleObjectsEx = function(nCount: DWORD; var pHandles;
+         dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD; stdcall;
+      TFuncGradientFill = function(DC: HDC; Vertex: PTriVertex; NumVertex: ULONG;
+         Mesh: Pointer; NumMesh, Mode: ULONG): BOOL; stdcall;
+ 
+ var FuncMsgWaitForMultipleObjectsEx: TFuncMsgWaitForMultipleObjectsEx;
+     FuncGradientFill: TFuncGradientFill;
+     dllUser32Handle, dllMSImg32Handle: THandle;
+ 
+ // Added 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
+ procedure LoadDynFromDLL;
+ begin
+    // user32.dll
+    FuncMsgWaitForMultipleObjectsEx := nil;
+    dllUser32Handle := 0;
+    dllUser32Handle := LoadLibrary(user32);
+    if dllUser32Handle>0 then try
+       FuncMsgWaitForMultipleObjectsEx
+        := TFuncMsgWaitForMultipleObjectsEx(GetProcAddress(dllUser32Handle,' MsgWaitForMultipleObjectsEx'));
+    except
+       FuncMsgWaitForMultipleObjectsEx := nil;
+       dllUser32Handle := 0;
+    end;
+    // msimg32.dll
+    FuncGradientFill := nil;
+    dllMSImg32Handle := 0;
+    dllMSImg32Handle := LoadLibrary(msimg32);
+    if dllMSImg32Handle>0 then try
+       FuncGradientFill
+        := TFuncGradientFill(GetProcAddress(dllMSImg32Handle, 'GradientFill'));
+    except
+       FuncGradientFill := nil;
+       dllMSImg32Handle := 0;
+    end;
+ end;
+ 
+ // Added 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
+ // http://msdn.microsoft.com/library/en-us/dllproc/base/msgwaitformultipleobjectsex.asp
+ function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles;
+   dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD; stdcall;
+ begin
+    if dllUser32Handle>0
+     then Result := FuncMsgWaitForMultipleObjectsEx(nCount, pHandles, dwMilliseconds, dwWakeMask, dwFlags)
+      else Result := MsgWaitForMultipleObjects(nCount, pHandles, false, dwMilliSeconds, dwWakeMask);
+    // using MsgWaitForMultipleObjects instead on Win95 is not properly tested yet.
+ end;
+ 
+ // Added 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
+ // http://msdn.microsoft.com/library/en-us/gdi/bitmaps_8oa4.asp
+ function GradientFill(DC: HDC; Vertex: PTriVertex; NumVertex: ULONG;
+                       Mesh: Pointer; NumMesh, Mode: ULONG): BOOL; stdcall;
+ begin
+    Result := false;
+    if dllMSImg32Handle>0
+     then Result := FuncGradientFill(DC, Vertex, NumVertex, Mesh, NumMesh, Mode);
+ end;
+ 
+ 
+ 
  initialization
    HtmlHelpModule := 0;
+   LoadDynFromDLL; // Added 2006-11-07 by Patrick Michael Kolla for Windows 95 compatibility
  finalization
    if HtmlHelpModule <> 0 then FreeLibrary(HtmlHelpModule);
  end.
