3,119
社区成员
发帖
与我相关
我的任务
分享
// Window graphics context
CWindowGc& gc = SystemGc();
// Area in which we shall draw
TRect drawRect = Rect();
// Default brush style
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
// Start with a clear screen
gc.SetBrushColor(KRgbWhite);
gc.Clear(drawRect);
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
// ERROR:在这里要是不给pen设置颜色,容易panic
gc.SetPenColor(KRgbBlack);
const CFont* fontUsed = iEikonEnv->TitleFont();
gc.UseFont(fontUsed);
TBuf<20> des = L"北京";
TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2;
gc.DrawText(des,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
gc.DiscardFont();