Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/HtmlRenderer.WinForms/HtmlLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/HtmlRenderer.WinForms/HtmlPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
24 changes: 15 additions & 9 deletions Source/HtmlRenderer.WinForms/HtmlToolTip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ public virtual Size MaximumSize
/// </summary>
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("<div{0}>{1}</div>", cssClass, GetToolTip(e.AssociatedControl));
Expand Down Expand Up @@ -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;
}
}


Expand Down
18 changes: 9 additions & 9 deletions Source/HtmlRenderer.WinForms/MetafileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 4 additions & 3 deletions Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// <summary>
/// Create a compatible memory HDC from the given HDC.<br/>
Expand Down
Loading