WSERV 14 and DrawText

Login to reply to this topic.
Thu, 2004-12-02 11:49
Joined: 2004-11-20
Forum posts: 67
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));
}


Huh

Thu, 2004-12-02 12:28
Joined: 2003-12-05
Forum posts: 696
WSERV 14 and DrawText
Quote
Printing with no active font.

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...
Fri, 2004-12-03 03:10
Joined: 2004-12-02
Forum posts: 9
WSERV 14 and DrawText
U should set an active font before u use  CWindowGc::UseFont()。
Fri, 2004-12-03 09:24
Joined: 2003-12-05
Forum posts: 696
WSERV 14 and DrawText
That's what I said (and the SDK docs too).
Sat, 2008-10-18 11:52
Joined: 2007-08-23
Forum posts: 16
Re: WSERV 14 and DrawText

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));

}

Thu, 2008-10-23 17:09
Joined: 2003-12-05
Forum posts: 696
Re: WSERV 14 and DrawText

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?

  • Login to reply to this topic.