diff --git a/Source/HtmlRenderer.WinForms/HtmlLabel.cs b/Source/HtmlRenderer.WinForms/HtmlLabel.cs
index 254566541..2fafa39e6 100644
--- a/Source/HtmlRenderer.WinForms/HtmlLabel.cs
+++ b/Source/HtmlRenderer.WinForms/HtmlLabel.cs
@@ -708,7 +708,7 @@ protected override void WndProc(ref Message m)
try
{
// Replace .NET's hand cursor with the OS cursor
- Win32Utils.SetCursor(Win32Utils.LoadCursor(0, Win32Utils.IdcHand));
+ Win32Utils.SetCursor(Win32Utils.LoadCursor(IntPtr.Zero, (IntPtr)Win32Utils.IdcHand));
m.Result = IntPtr.Zero;
return;
}
diff --git a/Source/HtmlRenderer.WinForms/HtmlPanel.cs b/Source/HtmlRenderer.WinForms/HtmlPanel.cs
index 9d150fd19..91c331fbf 100644
--- a/Source/HtmlRenderer.WinForms/HtmlPanel.cs
+++ b/Source/HtmlRenderer.WinForms/HtmlPanel.cs
@@ -798,7 +798,7 @@ protected override void WndProc(ref Message m)
try
{
// Replace .NET's hand cursor with the OS cursor
- Win32Utils.SetCursor(Win32Utils.LoadCursor(0, Win32Utils.IdcHand));
+ Win32Utils.SetCursor(Win32Utils.LoadCursor(IntPtr.Zero, (IntPtr)Win32Utils.IdcHand));
m.Result = IntPtr.Zero;
return;
}
diff --git a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs
index 9b6bb1eb8..7de567f96 100644
--- a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs
+++ b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs
@@ -238,6 +238,13 @@ public virtual Size MaximumSize
///
protected virtual void OnToolTipPopup(PopupEventArgs e)
{
+ // Shown for a window that isn't a control, there's no control to measure the html with
+ if (e.AssociatedControl == null)
+ {
+ e.Cancel = true;
+ return;
+ }
+
//Create fragment container
var cssClass = string.IsNullOrEmpty(_tooltipCssClass) ? null : string.Format(" class=\"{0}\"", _tooltipCssClass);
var toolipHtml = string.Format("
{1}
", cssClass, GetToolTip(e.AssociatedControl));
@@ -406,23 +413,22 @@ protected virtual void OnToolTipDisposed(EventArgs e)
Draw -= OnToolTipDraw;
Disposed -= OnToolTipDisposed;
+ if (_linkHandlingTimer != null)
+ {
+ _linkHandlingTimer.Tick -= OnLinkHandlingTimerTick;
+ _linkHandlingTimer.Dispose();
+ _linkHandlingTimer = null;
+ }
+
if (_htmlContainer != null)
{
+ _htmlContainer.LinkClicked -= OnLinkClicked;
_htmlContainer.RenderError -= OnRenderError;
_htmlContainer.StylesheetLoad -= OnStylesheetLoad;
_htmlContainer.ImageLoad -= OnImageLoad;
_htmlContainer.Dispose();
_htmlContainer = null;
}
-
- if (_linkHandlingTimer != null)
- {
- _linkHandlingTimer.Dispose();
- _linkHandlingTimer = null;
-
- if (_htmlContainer != null)
- _htmlContainer.LinkClicked -= OnLinkClicked;
- }
}
diff --git a/Source/HtmlRenderer.WinForms/MetafileExtensions.cs b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs
index 7bc5fad25..a4c1f8768 100644
--- a/Source/HtmlRenderer.WinForms/MetafileExtensions.cs
+++ b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs
@@ -14,24 +14,24 @@ public static void SaveAsEmf(Metafile me, string fileName)
by : SWAT Team member _1
Date : Friday, February 01, 2008 1:38 PM
*/
- int enfMetafileHandle = me.GetHenhmetafile().ToInt32();
- int bufferSize = GetEnhMetaFileBits(enfMetafileHandle, 0, null); // Get required buffer size.
- byte[] buffer = new byte[bufferSize]; // Allocate sufficient buffer
- if (GetEnhMetaFileBits(enfMetafileHandle, bufferSize, buffer) <= 0) // Get raw metafile data.
+ IntPtr enfMetafileHandle = me.GetHenhmetafile();
+ uint bufferSize = GetEnhMetaFileBits(enfMetafileHandle, 0, null); // Get required buffer size.
+ byte[] buffer = new byte[bufferSize]; // Allocate sufficient buffer
+ if (GetEnhMetaFileBits(enfMetafileHandle, bufferSize, buffer) == 0) // Get raw metafile data.
throw new SystemException("Fail");
FileStream ms = File.Open(fileName, FileMode.Create);
- ms.Write(buffer, 0, bufferSize);
+ ms.Write(buffer, 0, buffer.Length);
ms.Close();
ms.Dispose();
if (!DeleteEnhMetaFile(enfMetafileHandle)) //free handle
throw new SystemException("Fail Free");
}
- [DllImport("gdi32")]
- public static extern int GetEnhMetaFileBits(int hemf, int cbBuffer, byte[] lpbBuffer);
+ [DllImport("gdi32.dll")]
+ public static extern uint GetEnhMetaFileBits(IntPtr hemf, uint cbBuffer, byte[] lpbBuffer);
- [DllImport("gdi32")]
- public static extern bool DeleteEnhMetaFile(int hemfbitHandle);
+ [DllImport("gdi32.dll")]
+ public static extern bool DeleteEnhMetaFile(IntPtr hemf);
}
}
diff --git a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs
index 228e47658..201e3f3ab 100644
--- a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs
+++ b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs
@@ -48,10 +48,11 @@ internal static class Win32Utils
public const int TextAlignBaselineRtl = 256 + 24;
[DllImport("user32.dll")]
- public static extern int SetCursor(int hCursor);
+ public static extern IntPtr SetCursor(IntPtr hCursor);
- [DllImport("user32.dll")]
- public static extern int LoadCursor(int hInstance, int lpCursorName);
+ // The cursor name is a pointer, a predefined cursor like IdcHand is an ID cast to one
+ [DllImport("user32.dll", EntryPoint = "LoadCursorW")]
+ public static extern IntPtr LoadCursor(IntPtr hInstance, IntPtr lpCursorName);
///
/// Create a compatible memory HDC from the given HDC.