Unable to use CWindowGC::Drawtext API
| Fri, 2007-10-12 12:37 | |
|
Hi Friends, below is my function: CSampleAppUIView class is derived from CCoeControl. void CSampleAppUIView::TextDraw(const TDesC& aText, const TPoint& aPoint) string for aText is coming for a descriptor HBufC. I am not able to proceed with my application, can anybody help me. |
|






Forum posts: 1134
You shouldn't just draw to the gc anytime as you try to do now.
The right way is to implement the Draw() method of a CCoeControl or view to draw the text.
This method will be called by the framework each time the control needs to be drawn, (for example when closing a menu that covered it, or when telling it to be visible) and you can, if needed, initiate a redraw by calling DrawNow().
It will take care of activation and deactivation for you, which might be your problem now (hard to say since you don't say how your app "crash". Try find out the panic error code to get more information on why your app dies.)
Forum posts: 14
Wheneve you want to update screen please call DrawNow or DrawDeferred.
Forum posts: 84
Hi KamalPreet,
Use following cade :
Window().Invalidate();
ActivateGc();
Window().BeginRedraw();
CWindowGc& gc = SystemGc();
gc.UseFont(iEikonEnv->TitleFont());
gc.DrawText(aText, Rect().Center());
Window().EndRedraw();
DeactivateGc();
This code may be solve your problem.
Thanks And Regards,
Yogesh
Forum posts: 1134
No. Don't use that code.
Its much better to just implement the draw function of a CCoeControl, and display this one.
Yogesh code will work to output some text on the screen, but it is a very hacky way to do it, and will produce errors whenever your view gets a redraw event.
(parts or all of the text will disappear from the screen, and not be redrawn until this code is called again)
If you implement the Draw function, the framework will do all those BeginRedraw/EndRedraw and such for you, so you wont have to write that code yourself, plus any redraws of the view will also work.