| Version: 3.2.2

Public Member Functions | List of all members
wxBusyInfo Class Reference
Class List by Category » Common Dialogs

`#include <wx/busyinfo.h>`

## Detailed Description

This class makes it easy to tell your user that the program is temporarily busy.

Normally the main thread should always return to the main loop to continue dispatching events as quickly as possible, hence this class shouldn't be needed. However if the main thread does need to block, this class provides a simple way to at least show this to the user: just create a wxBusyInfo object on the stack, and within the current scope, a message window will be shown.

For example:

wxBusyInfo wait("Please wait, working...");
for (int i = 0; i < 100000; i++)
{
DoACalculation();
}
wxBusyInfo
This class makes it easy to tell your user that the program is temporarily busy.
Definition: busyinfo.h:86

It works by creating a window in the constructor, and deleting it in the destructor.

This window is rather plain by default but can be customized by passing wxBusyInfo constructor an object of wxBusyInfoFlags class instead of a simple message. Here is an example from the dialogs sample:

wxBusyInfo info
(
wxBusyInfoFlags()
.Parent(this)
.Icon(wxArtProvider::GetIcon(wxART_PRINT,
wxART_OTHER, wxSize(128, 128)))
.Title("<b>Printing your document</b>")
.Text("Please wait...")
.Foreground(*wxWHITE)
.Background(*wxBLACK)
.Transparency(4*wxALPHA_OPAQUE/5)
);
wxART_PRINT
const char * wxART_PRINT
Definition: artprov.h:50
wxART_OTHER
const char * wxART_OTHER
Definition: artprov.h:29
wxArtProvider::GetIcon
static wxIcon GetIcon(const wxArtID &id, const wxArtClient &client=wxART_OTHER, const wxSize &size=wxDefaultSize)
Same as wxArtProvider::GetBitmap, but return a wxIcon object (or wxNullIcon on failure).
wxBusyInfoFlags
Parameters for wxBusyInfo.
Definition: busyinfo.h:164
wxSize
A wxSize is a useful data structure for graphics operations.
Definition: gdicmn.h:940
wxBLACK
wxColour * wxBLACK
Definition: colour.h:362
wxWHITE
wxColour * wxWHITE
Definition: colour.h:369
wxALPHA_OPAQUE
const unsigned char wxALPHA_OPAQUE
Definition: colour.h:23

This shows that separate title and text can be set, and that simple markup (wxControl::SetLabelMarkup()) can be used in them, and that it's also possible to add an icon and customize the colours and transparency of the window.

You may also want to call wxTheApp->Yield() to refresh the window periodically (in case it had been obscured by other windows, for example) like this:

wxWindowDisabler disableAll;
wxBusyInfo wait("Please wait, working...");
for (int i = 0; i < 100000; i++)
{
DoACalculation();
if ( !(i % 1000) )
wxTheApp->Yield();
}
wxAppConsole::Yield
bool Yield(bool onlyIfNeeded=false)
Yields control to pending messages in the event loop.
wxWindowDisabler
This class disables all top level windows of the application (maybe with the exception of one of them...
Definition: utils.h:77
wxTheApp
wxApp * wxTheApp
The global pointer to the singleton wxApp object.
Definition: app.h:1310

but take care to not cause undesirable reentrancies when doing it (see wxApp::Yield for more details). The simplest way to do it is to use wxWindowDisabler class as illustrated in the above example.

Note that a wxBusyInfo is always built with the `wxSTAY_ON_TOP` window style (see wxFrame window styles for more info).

##

Library: wxCore
Category: Common Dialogs

## Public Member Functions

| wxBusyInfo (const wxBusyInfoFlags &flags)
| General constructor. More...
| wxBusyInfo (const wxString &msg, wxWindow *parent=NULL)
| Simple constructor specifying only the message and the parent. More...
void | UpdateText (const wxString &str)
| Update the information text. More...
void | UpdateLabel (const wxString &str)
| Same as UpdateText() but doesn't interpret the string as containing markup. More...
virtual | ~wxBusyInfo ()
| Hides and closes the window containing the information text. More...

## Constructor & Destructor Documentation

## ◆ wxBusyInfo() [1/2]

wxBusyInfo::wxBusyInfo | ( | const wxBusyInfoFlags & | flags | ) |

General constructor.

This constructor allows specifying all supported attributes by calling the appropriate methods on wxBusyInfoFlags object passed to it as parameter. All of them are optional but usually at least the message should be specified.

Since
  3.1.0

## ◆ wxBusyInfo() [2/2]

wxBusyInfo::wxBusyInfo | ( | const wxString & | msg,
|  | wxWindow * | parent = `NULL`
| ) |  |

Simple constructor specifying only the message and the parent.

This constructs a busy info window as child of parent and displays msg in it. It is exactly equivalent to using

wxBusyInfo(wxBusyInfoFlags().Parent(parent).Label(message))
wxBusyInfo::wxBusyInfo
wxBusyInfo(const wxBusyInfoFlags &flags)
General constructor.

Note
  If parent is not NULL you must ensure that it is not closed while the busy info is shown.

## ◆ ~wxBusyInfo()

virtual wxBusyInfo::~wxBusyInfo | ( |  | ) |

virtual

Hides and closes the window containing the information text.

## Member Function Documentation

## ◆ UpdateLabel()

void wxBusyInfo::UpdateLabel | ( | const wxString & | str | ) |

Same as UpdateText() but doesn't interpret the string as containing markup.

Since
  3.1.3

## ◆ UpdateText()

void wxBusyInfo::UpdateText | ( | const wxString & | str | ) |

Update the information text.

The text string may contain markup as described in wxControl::SetLabelMarkup().

Since
  3.1.3