|
|
User login
Feeds |
WSERV 14 and DrawText
|
|||||
| Thu, 2004-12-02 11:49 | |
|
Hi,
When I use this Draw method, it works cool: void CMyApp::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); gc.Clear(aRect); //Set GC pen & brush styles gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenColor(KRgbRed); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetBrushColor(KRgbRed); gc.DrawEllipse(aRect); } but when change last line, I get this run time error: App.Closed MyApp WSERV 14 void CMyApp::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); gc.Clear(aRect); //Set GC pen & brush styles gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenColor(KRgbRed); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetBrushColor(KRgbRed); gc.DrawText(_L("P"),TPoint(162,173)); } ![]() |
|
Forum posts: 696
A command to draw text to a window was sent to a graphics context when no font was set. Any of the overloads of CWindowGc::DrawTextVertical() or CWindowGc::DrawText() might cause the panic to be raised; the font should be set using CWindowGc::UseFont() first.
On the server side, this panic is raised by CWsGc::DoDrawCommand() in response to any of the requests to display text defined in TWsGcOpcodes.
So you have to select a font before drawing text...
Forum posts: 9
Forum posts: 696
Forum posts: 16
This sample working fine.
void CPicActiveAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect(Rect());
// Clears the screen
gc.Clear(drawRect);
CFont const *font;
font = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
//font = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
gc.UseFont(font);
TUint16 text[] = L"aaaa";
TPtrC ptr(text);
TBuf<100> text16;
text16 = ptr;
gc.DrawText(text16,TPoint(40,40));
}
Forum posts: 696
KVV, do you realize that you just "contributed" to a thread four years old? And with a code sample that is S60 specific as you could have done it generically so that it also works in UIQ? And with a code sample that is overly complicating things?