How to get ReDraw event in exe from window server?
Article Metadata
Why it is required?
When you draw something in exe (without CONE environment), you will not get redraw event automatically. It is required because when some part of your rect gets invalid than you have to validate it again. Possible cases when your rect might get invalid are opening other aap, receive call, receive SMS etc.
How to implement it?
We have to request redraw events from the window server, we can do this by the RedrawReady method of window server. We also need to create an active object for redraw events.
CMyReDraw::CMyReDraw(RWsSession& aWsSession): CActive(CActive::EPriorityStandard), iWsSession(aWsSession)
{
CActiveScheduler::Add(this);
iStatus = KRequestPending;
//iWsSession is your window server session and assuming u have created it.
iWsSession.RedrawReady(&iStatus);
SetActive();
}
CMyReDraw::~CMyReDraw()
{
Cancel();
}
void CMyReDraw::RunL()
{
TWsRedrawEvent e;
//GetRedraw will give you redraw event
iWsSession.GetRedraw(e);
//you can call your drawing function here.
iStatus = KRequestPending;
//you should not call RedrawReady again until you've either called GetRedraw() or RedrawReadyCancel().
iWsSession.RedrawReady(&iStatus);
SetActive();
}
void CMyReDraw::DoCancel()
{
iWsSession.RedrawReadyCancel();
}


06 Sep
2009
CONE environment will pass the redraw event to the application which is in foreground. By default exe in symban does not have CONE environment in it, So if your exe have graphics in it than it require redraw events issued by window server. It is required when your application is overlapped by some other application, for example call dialog overlapped your application and then disappear after some time, so your application need invalid rect overlapped by call dialog. Thus we need to implement listener to get redraw event issued by window server.
Article describes basic steps required to implement redraw event listener. This require use of Active Objects, so basic knowledge of Active objects is necessary. Article is useful to both beginners as well as experienced developer.