L
Luke R
It would be much appreciated... Im not familiar enough with C in order to
convert it myself...
thanks
using System;
using System.Windows.Forms;
public class HourGlass : IDisposable {
public HourGlass() {
Enabled = true;
}
public void Dispose() {
Enabled = false;
}
public static bool Enabled {
get { return Application.UseWaitCursor; }
set {
if (value == Application.UseWaitCursor) return;
Application.UseWaitCursor = value;
Form f = Form.ActiveForm;
if (f != null && f.Handle != null) // Send WM_SETCURSOR
SendMessage(f.Handle, 0x20, f.Handle, (IntPtr)1);
}
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp,
IntPtr lp);
}
You can use it either directly by assigning HourGlass.Enabled or like this:
private void button1_Click(object sender, EventArgs e) {
using (new HourGlass()) {
// Do something that takes time...
System.Threading.Thread.Sleep(2000);
}
}
convert it myself...
thanks
using System;
using System.Windows.Forms;
public class HourGlass : IDisposable {
public HourGlass() {
Enabled = true;
}
public void Dispose() {
Enabled = false;
}
public static bool Enabled {
get { return Application.UseWaitCursor; }
set {
if (value == Application.UseWaitCursor) return;
Application.UseWaitCursor = value;
Form f = Form.ActiveForm;
if (f != null && f.Handle != null) // Send WM_SETCURSOR
SendMessage(f.Handle, 0x20, f.Handle, (IntPtr)1);
}
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp,
IntPtr lp);
}
You can use it either directly by assigning HourGlass.Enabled or like this:
private void button1_Click(object sender, EventArgs e) {
using (new HourGlass()) {
// Do something that takes time...
System.Threading.Thread.Sleep(2000);
}
}