/// <summary> /// Displays the progress dialog and starts the timer. /// </summary> /// <param name="parent">The dialog box's parent window.</param> public void Show(IWin32Window parent) { // Throw an exception if we are already running if (_state != ProgressDialogState.Stopped) { throw new InvalidOperationException("Timer is already running."); } // Get parent window handle if (parent == null) { parent = Form.ActiveForm; } IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle; // Setup the window _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType); _nativeProgressDialog.SetTitle(_title); _nativeProgressDialog.SetCancelMsg(_cancelMessage, null); if (ShowTimeRemaining) { _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero); } // Create Window _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero); _value = 0; _state = ProgressDialogState.Running; _nativeProgressDialog.Timer(PDTIMER.Reset, null); }
private void button1_Click(object sender, EventArgs e) { ProgressDialog progressDialog = new ProgressDialog(); IProgressDialog iProgressDialog = (IProgressDialog)progressDialog; iProgressDialog.Timer((uint)IPDTIMER_Flags.Resume, null); iProgressDialog.StartProgressDialog(this.Handle , null , (uint)(IPD_Flags.Normal | IPD_Flags.NoMinimize) , IntPtr.Zero); }
/// <summary> /// Displays the progress dialog and starts the timer. /// </summary> /// <param name="parent">The dialog box's parent window.</param> public void Show(IWin32Window parent) { if (_state != ProgressDialogState.Stopped) { throw new InvalidOperationException("Timer is already running."); } if (parent == null) { parent = Form.ActiveForm; } IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle; _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType); _nativeProgressDialog.SetCancelMsg(_cancelMessage, null); if (ShowTimeRemaining) { _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero); } //Temporary title for progressbar handler detection string guidTitle = Guid.NewGuid().ToString(); _nativeProgressDialog.SetTitle(guidTitle); _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero); //Workaround to manipulate progressbar style IntPtr handler = IntPtr.Zero; while (true) { handler = FindWindow(null, guidTitle); if (handler == IntPtr.Zero) { Thread.Sleep(25); } else { break; } } handler = FindWindowEx(handler, IntPtr.Zero, "DirectUIHWND", null); IntPtr childHandler = FindWindowEx(handler, IntPtr.Zero, "CtrlNotifySink", null); childHandler = FindWindowEx(handler, childHandler, "CtrlNotifySink", null); childHandler = FindWindowEx(handler, childHandler, "CtrlNotifySink", null); _progressBarHandler = FindWindowEx(childHandler, IntPtr.Zero, "msctls_progress32", null); //Real title _nativeProgressDialog.SetTitle(_title); _value = 0; _state = ProgressDialogState.Running; _nativeProgressDialog.Timer(PDTIMER.Reset, null); }
/// <summary> /// Displays the progress dialog and starts the timer. /// </summary> /// <param name="parent">The dialog box's parent window.</param> public void Show(IWin32Window parent) { if (_state != ProgressDialogState.Stopped) throw new InvalidOperationException("Timer is already running."); if (_parentForm == null) _parentForm = Form.ActiveForm; IntPtr handle = parent?.Handle ?? IntPtr.Zero; //_nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType); _nativeProgressDialog = (IProgressDialog) new ProgressDialogImpl(); _nativeProgressDialog.SetTitle(_title); _nativeProgressDialog.SetCancelMsg(_cancelMessage, null); if (ShowTimeRemaining) _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero); _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero); _value = 0; _state = ProgressDialogState.Running; _nativeProgressDialog.Timer(PDTIMER.Reset, null); _statePollingTimer.Change(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(250)); }
/// <summary> /// Displays the progress dialog and starts the timer. /// </summary> /// <param name="parent">The dialog box's parent window.</param> public void Show(IWin32Window parent) { // Throw an exception if we are already running if (_state != ProgressDialogState.Stopped) throw new InvalidOperationException("Timer is already running."); // Get parent window handle if (parent == null) parent = Form.ActiveForm; IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle; // Setup the window _nativeProgressDialog = (IProgressDialog)Activator.CreateInstance(_progressDialogType); _nativeProgressDialog.SetTitle(_title); _nativeProgressDialog.SetCancelMsg(_cancelMessage, null); if (ShowTimeRemaining) _nativeProgressDialog.SetLine(3, "Estimating time remaining...", false, IntPtr.Zero); // Create Window _nativeProgressDialog.StartProgressDialog(handle, null, _flags, IntPtr.Zero); _value = 0; _state = ProgressDialogState.Running; _nativeProgressDialog.Timer(PDTIMER.Reset, null); }