×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2007
    Location
    Bangalore
    Posts
    8

    Question Problem with DrawText()

    Hi, I am trying to create a custom control (COnTopText) which stays always on top of the screen and carries some text in it.

    I am trying to draw the text using CWindowGc:rawText(), but for some reason I am not able to get it work.



    Here is my code:

    Code:
    void COnTopText::ConstructL()
    {
    	iMyWinowGroup = RWindowGroup( iCoeEnv->WsSession());
    	User::LeaveIfError( iMyWinowGroup.Construct( (TUint32) &iMyWinowGroup) );
    	
    	iMyWinowGroup.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront );
    	iMyWinowGroup.EnableReceiptOfFocus( EFalse );
    	
    	CreateWindowL( &iMyWinowGroup );
    	SetRect(TRect(5,250,235,279));
    	ActivateL();	
    	DrawNow();	
    }
    
    void COnTopText::Draw( TRect &aRect ) const
    {
    	CWindowGc &gc = SystemGc();
    	
    	gc.Clear();
    	gc.UseFont( iCoeEnv->NormalFont());
    	gc.SetPenColor( TRgb( 0, 0, 0xFF ));
    	gc.DrawText( KMyText, TPoint( 7, 252 ) );
    }
    Please help...

  2. #2
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Problem with DrawText()

    Watch out the coordinates. Note that when drawing, it is relative to the control, not the window.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Location
    Bangalore
    Posts
    8

    Re: Problem with DrawText()

    I tried with each and every combination of the co-ordinates possible, but still could not see any text written.

    Am I missing something else (perhaps with gc?)

    Code:
    void COnTopText::Draw( TRect &aRect ) const
    {
    	CWindowGc &gc = SystemGc();
    	
    	gc.Clear();
    	gc.UseFont( iCoeEnv->NormalFont());
    	gc.SetPenColor( TRgb( 0, 0, 0xFF ));
    	TInt x, y;
    	// This code assumes relavtive co-ordinates
    	for( x = 1; x < ( 235 - 5 ); x++ )
    	{
    		for( y = 1; y < ( 279 - 250 ); y++ )
    		{
    			gc.DrawText( KMyText, TPoint( x, y ) );
    		}
    	}
    	// This might work if absolute co-cordinates are needed by DrawText()
    	for( x = 6; x < 235; x++ )
    	{
    		for( y = 251; y < 279; y++ )
    		{
    			gc.DrawText( KMyText, TPoint( x, y ) );
    		}
    	}
    }

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Problem with DrawText()

    Note that your method never gets invoked (BTW: why do not you use a debugger??), const matters in the method signature, there should be two occurences.

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×