CActiveScheduler::Add(this);
User::LeaveIfError(iWsSession.Connect());
iScreenDevice=new (ELeave) CWsScreenDevice(iWsSession);
User::LeaveIfError(iScreenDevice->Construct());
User::LeaveIfError(iScreenDevice->CreateContext(iWindowGc));
TFontSpec MyeFontSpec (KFontArial, 12*15);
MyeFontSpec.iTypeface.SetIsProportional(ETrue);
User::LeaveIfError(iScreenDevice->GetNearestFontInTwips(iMyFont,MyeFontSpec));
iWindowGroup=RWindowGroup(iWsSession);
User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup, EFalse));
// iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityNormal);
iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
iWindowGroup.EnableReceiptOfFocus(EFalse);
CApaWindowGroupName* winGroupName=CApaWindowGroupName::NewLC(iWsSession);
winGroupName->SetHidden(ETrue);
winGroupName->SetWindowGroupName(iWindowGroup);
CleanupStack::PopAndDestroy();
iWindow=RWindow(iWsSession);
User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32)&iWindow));
TPixelsTwipsAndRotation SizeAndRotation;
iScreenDevice->GetDefaultScreenSizeAndRotation(SizeAndRotation);
iWindow.Activate();
//iWindow.SetExtent(TPoint(0,0),SizeAndRotation.iPixelSize);
iWindow.SetExtent(TPoint(0,0),TSize(240,40));
iWindow.SetBackgroundColor(KRgbBlue);
// iWindow.SetOrdinalPosition(0,ECoeWinPriorityNormal);
iWindow.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iWindow.SetNonFading(ETrue);
iWindow.SetVisible(ETrue);
SetWhere(aArea);
Draw();
iWsSession.RedrawReady(&iStatus);
SetActive();
}
//监听到绘制消息后,绘制字符串
void CWindowDrawer::RunL()
{
if (iStatus != KErrCancel)
{
TWsRedrawEvent e;
iWsSession.GetRedraw(e);
// if Windows Server does not want a redraw the window handle is 0
if (e.Handle() != 0)
{
// draw our only window
Draw();
}
iWsSession.RedrawReady(&iStatus);
SetActive();
}
}
//绘制字符串
void CWindowDrawer::Draw()
{
iWindowGc->Activate(iWindow);
TRect DrwRect(TPoint(0,0), iWindow.Size());
iWindow.Invalidate(DrwRect);
iWindow.BeginRedraw();
iWindowGc->Clear(DrwRect);
if(iMyFont)
{
iWindowGc->UseFont(iMyFont);
TInt StartY ((DrwRect.Height() - iMyFont->HeightInPixels()) / 2);
iWindowGc->SetPenColor(TRgb(255,0,0));
if(iWhereArea != NULL)
{
iWindowGc->DrawText(iWhereArea->Des(),TRect(0,StartY,DrwRect.Width
(),(StartY + iMyFont->HeightInPixels())),iMyFont->AscentInPixels(),
CGraphicsContext::ECenter, 0);
}
else
{
iWindowGc->DrawText(_L("/x672A/x77E5/x7535/x8BDD"),TRect
(0,StartY,DrwRect.Width(),(StartY + iMyFont->HeightInPixels())),iMyFont->AscentInPixels(),
CGraphicsContext::ECenter, 0);
}
}
iWindow.EndRedraw();
iWindowGc->Deactivate();
iWsSession.Flush();
}
以上代码在N73/N95/6120c上测试通过
Symbian 后台程序如何在桌面上绘制文本效果
大家用过来电通的朋友都会知道.
当来电或者去电的时候.桌面上会有地区号码的文字显示.
那这种效果应该如何实现呢.
其实非常的简单,让我们今天来看看这种效果是如何实现的.
小弟最近也仿写了一个字样的效果,自我感觉还是不错的.
特在此总结一下为自己留个脚印没准其他网友也用得着.
哈哈少费话了进入正题了.
//初始化窗口
void CWindowDrawer::ConstructL(const TDesC& aArea)
{
大家用过来电通的朋友都会知道.
当来电或者去电的时候.桌面上会有地区号码的文字显示.
那这种效果应该如何实现呢.
其实非常的简单,让我们今天来看看这种效果是如何实现的.
小弟最近也仿写了一个字样的效果,自我感觉还是不错的.
特在此总结一下为自己留个脚印没准其他网友也用得着.
哈哈少费话了进入正题了.
//初始化窗口
void CWindowDrawer::ConstructL(const TDesC& aArea)
{