| Reply | « Previous Thread | Next Thread » |
|
Hey guys,
I'm trying to draw fomatted text on the screen, but the text goes out garbled - usually squares, but sometimes other garbage. The problem is either with TBuf's Format method, or with DrawText getting TBuf. Anyway, it doesn't happen when I just use the resource directly, as can be seen in the code below. Code:
_LIT(KREPORT, "%s");
_LIT(KRESOURCE, "something");
TBuf<10> message;
message.Format(KREPORT, "something");
CWindowGc& gc = SystemGc();
gc.Activate(Window());
gc.UseFont(CEikonEnv::Static()->TitleFont());
gc.SetPenColor(KRgbGreen);
TPoint p1(10, 20);
gc.DrawText(message, p1);
TPoint p2(10, 60);
gc.DrawText(KRESOURCE, p2);
gc.Deactivate();
Anyone got an idea why this should happen or how to solve it? Cheers, Nate. Cheers, Nate |
|
Hi,
Why you need this line Quote:
============================= Before to ask the question, Few things to be remind 1- Check wiki.forum.nokia 2- Forum.nokia.com, developer.symbian.org 3- Check on google |
|
Quote:
Thanks for your answer. I'm trying to save four messages in an array and draw them on the four corners of the screen. They keep being updated, so I need to draw directly from the array and update the array from char *. Code:
class CSomething
{
...
private:
TBuf<10> iMessages[4];
int ixOffset;
int iyOffset;
TPoint iCorners[4];
}
void CSomething::InitReport()
{
const TText *t = _S("");
for (int i=0; i<4; i++)
iMessages[i] = t;
ixOffset = 10;
iyOffset = 20;
iCorners[0] = TPoint(ixOffset, iyOffset);
iCorners[1] = TPoint(IMAGE_WIDTH-ixOffset, iyOffset);
iCorners[2] = TPoint(ixOffset, IMAGE_HEIGHT-iyOffset);
iCorners[3] = TPoint(IMAGE_WIDTH-ixOffset, IMAGE_HEIGHT-iyOffset);
}
void CSomething::Report(char *aWhat, TCorner aCorner)
{
_LIT(KREPORT, "%s");
switch (aCorner)
{
case ETL:
iMessages[0].Format(KREPORT, aWhat);
break;
case ETR:
iMessages[1].Format(KREPORT, aWhat);
break;
case EBL:
iMessages[2].Format(KREPORT, aWhat);
break;
case EBR:
iMessages[3].Format(KREPORT, aWhat);
break;
}
}
void CSomething::DrawText(char *aWhat, TCorner aCorner)
{
CWindowGc& gc = SystemGc();
gc.Activate(Window());
gc.UseFont(CEikonEnv::Static()->TitleFont());
gc.SetPenColor(KRgbGreen);
for (int i=0; i<4; i++)
gc.DrawText(iMessages[i], iCorners[i]);
gc.Deactivate();
}
![]() Cheers, Nate. Cheers, Nate |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to display text stored in a TBuf or TDesc? | s3ni | Symbian User Interface | 17 | 2009-08-10 09:45 |
| Exit form from edit mode | tqchcm | Symbian User Interface | 13 | 2007-10-31 07:06 |
| How can I get the text buffer after DrawText()? | danie78 | General Symbian C++ | 2 | 2006-06-08 13:13 |
| Persist text value of user defined option in Enumerated Text Settings List | leethomso | Symbian User Interface | 0 | 2004-11-24 19:49 |
| How to display text stored in a TBuf or TDesc? | s3ni | General Symbian C++ | 1 | 2003-07-16 09:07 |