每一个细节搞懂都很艰难,drawtext画字,屏幕确没有显示
nokia VRex例子,我画图字确没有显示,是什么原因void CVRexVideoContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
//gc.SetPenStyle( CGraphicsContext::ENullPen );
//gc.SetBrushColor( KRgbGray );
//gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
//gc.DrawRect( aRect );
gc.UseFont(iEikonEnv->NormalFont());
//gc.Clear();
TPoint p(40,40);
gc.DrawText(_L("111111"),p);
gc.DiscardFont();
} --------------------编程问答-------------------- Text drawing is subject to the drawing mode, the current font, pen colour, word justification and character justification.
尝试1下,SetPenColor()
也许是默认的颜色看不出变化! --------------------编程问答-------------------- SetPenStyle(ESolidPen);
DrawNow刷新 --------------------编程问答-------------------- 正好有个例子给你
// Window graphics context--------------------编程问答-------------------- 改了也无法显示 --------------------编程问答-------------------- 我刚好也被耍了一下,坐标一定不能用TPoint(0,0),笔的颜色要设!
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();
_L("") 可能有问题? --------------------编程问答-------------------- draw函数好像不好调试吧
--------------------编程问答-------------------- 为什么不好调试呢? --------------------编程问答-------------------- 要设置设画笔的style,color,坐标纵坐标值不能设为0,因为,drawtext的TPoint是指他的左下角的坐标。 --------------------编程问答--------------------

我在uiq上运行了你的代码,没有问题。请看这个图。
我发的代码也是在uiq上的,很抱歉,没有说明平台。 --------------------编程问答-------------------- CWindowGc& gc = SystemGc();
TRect rect=Rect();
gc.Clear(rect);
试试。。。 --------------------编程问答-------------------- 接分先!
补充:移动开发 , Symbian