WinForms Overlay Forms - Coming soon in v18.1

Oliver's Blog
09 April 2018

Many of you are probably familiar with the Splash Screen Manager and its Wait Forms. These tiny elements implement a solution for the popular scenario of displaying a loading panel to indicate that the application is currently busy.

Wait Forms are good enough when all code executes in the UI thread and the application UI locks up. However, with asynchronous operations natively supported in C# using the async and await keywords, more programmers employ background threads to execute long-running processes, such as massive calculations or data retrieval operations. In these scenarios, the application UI remains responsive, and even when a Wait Form is being shown, end users can still drag and drop child form elements, modify editor content, press Ribbon buttons etc. This is undesirable and a different solution is required for these scenarios.

Responding to your requests, the Splash Screen Manager supports a new element, the Overlay Form, starting with the v18.1 release. The Overlay Form is a semi-transparent splash screen that runs in a background thread and prevents access to a control or form by displaying an overlay.

An associated control is grayed out when the Overlay Form is active, providing a clear visual message indicating that this control is currently unavailable. The control can be a Form, but you can also pass a basic Control. For instance, it would make sense to pass a root control on a form to ShowOverlayForm, so that the form itself could still be dragged by its title bar.

Overlay Form

To show and hide Overlay Forms, call the static ShowOverlayForm and CloseOverlayForm methods in code.

using DevExpress.XtraSplashScreen;

// ... Inside a form class,
// two small helper methods:

IOverlaySplashScreenHandle ShowProgressPanel() {
  // Pass "this" to use the current form as the "parent"
  return SplashScreenManager.ShowOverlayForm(this);
}

void CloseProgressPanel(IOverlaySplashScreenHandle handle) {
  if(handle != null)
    SplashScreenManager.CloseOverlayForm(handle);
}

// Finally, within the context of a long-running operation:

IOverlaySplashScreenHandle handle = null;

try {
  handle = ShowProgressPanel();

  // Now perform the long-running operation while
  // the Overlay Form overlaps the current form.
}
finally {
  CloseProgressPanel(handle);
}

You don’t need to manually modify Overlay Form appearance, as it automatically adapts to the current application skin. However, if required, you can edit look-and-feel settings or implement a custom painter to change the appearance of an Overlay Form completely.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.