To display a simple dialog box:
construct an RNotifier
object and then call its
Connect()
member function to create a session with the Notifier
server.
call the Notify()
member function of the
RNotifier
, passing descriptors containing the two lines of text to
be displayed and the characters for the buttons. Notify()
makes an
asynchronous request to the notifier server.
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.