-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPleaseWait.cs
43 lines (32 loc) · 1.04 KB
/
PleaseWait.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Grepy2
{
public partial class PleaseWait : Form
{
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool PostMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public PleaseWait()
{
InitializeComponent();
}
private void PleaseWait_Shown(object sender, EventArgs e)
{
progressBar1.Value = 0;
Application.DoEvents(); // this will cause the form to fully update itself before continuing (so that everything is fully rendered)
Globals.bPleaseWaitDialogCancelled = false;
HandleRef FormHandle = new HandleRef(this, Globals.MainFormHandle);
PostMessage(FormHandle, Globals.WM_PLEASEWAITSHOWN_NOTIFY_MAIN_THREAD, IntPtr.Zero, IntPtr.Zero);
}
private void button1_Click(object sender, EventArgs e)
{
Globals.bPleaseWaitDialogCancelled = true;
}
public void UpdateProgressBar(int value)
{
progressBar1.Value = value;
}
}
}