Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to use a notifier to display a simple dialog, asynchronously

To display a simple dialog box:

When the user keys in one of the button characters, the requesting thread's request semaphore is signalled to indicate that the notifier request is complete. The TRequestStatus object supplied by the requesting thread is set to KErrNone.

In addition, a TInt, passed by reference to Notify(), is set to 0 or 1 depending on whether the first or the second button is selected.

The session is closed by calling the Close() member function of the RNotifier.

The following code fragments demonstrate this:

{
_LIT(KTxtLine1,"First line");
_LIT(KTxtLine2,"Second line");
_LIT(KButt1,"a");
_LIT(KButt2,"b");
...
TInt           whichbutton(-1);
TRequestStatus stat;
...
RNotifier      notifier;
...
notifier.Connect();
...
notifier.Notify(KTxtLine1,KTxtLine2,KButt1,KButt2,whichbutton,stat);
...
// other code
...
User::WaitForRequest(stat);
...
if (whichbutton==0)
    {
    // first button selected
    }
if (whichbutton==1)
    {
    // Second button selected
    }
...
notifier.Close();
...
}

Note that the descriptor parameters passed to Notify() must remain in existence until the notify request completes; this may be some time after the call to Notify() itself.