I have to draw on window from server application (exe). I am interested if someone manage to do so.

Here is my code:

ConstructL:

iWsSession.Connect();
TInt winGroupHandle = iWsSession.GetWindowGroupHandle(0);
iWinGroup = RWindowGroup(iWsSession);

iWinGroupName = CApaWindowGroupName::NewL(iWsSession);
User::LeaveIfError(iWinGroup.Construct(winGroupHandle, EFalse));
iWinGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iWinGroupName->SetWindowGroupName(iWinGroup);

TInt ret = iWinGroup.CaptureKeyUpAndDowns(EStdKeyYes, 0, 0);

iWsSession.EventReady(&iStatus);
SetActive();


RunL():

DrawWindow(); // my method


DrawWindow:

iWindow = RWindow(iWsSession);
// Create a screen device
iScreen=new(ELeave) CWsScreenDevice(iWsSession);
User::LeaveIfError(iScreen->Construct());
User::LeaveIfError(iScreen->CreateContext(iWindowGc));
iWindowGc->Activate(iWindow);
TRect win(0, 0, 100, 100);
TRect ellipse(5, 5, 30, 30);

iWindow.Invalidate();
iWindow.BeginRedraw();

iWindowGc->Clear(win);
iWindowGc->SetPenStyle(CGraphicsContext::ESolidPen);
iWindowGc->SetPenColor(KRgbRed);
iWindowGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
iWindowGc->SetBrushColor(KRgbRed);
iWindowGc->DrawEllipse(ellipse);

iWindow.EndRedraw();
iWindowGc->Deactivate();


After this my screen is empty. Is there anything i am missing?

Thnx