×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    About Draw() function

    I have called ActivateL() in Constructor of the container. Then after ActivateL() the next line i have written is subDraw();

    subDraw() definition is as follows:
    void MyContainer::subDraw() const
    {
    TRect rect(TPoint(50,50),TSize(100,100));
    CWindowGc &gc = SystemGc();
    gc.SetPenColor(KRgbRed);
    gc.SetBrushColor(KRgbWhite);
    gc.DrawRect(rect);
    }

    Then the application crashes...
    But if in the constructor at the same line I write DrawNow() after ActivateL()... then the code works. Draw also does the same functionality as subDraw(). Why does it behave this way ? Can we draw from other functions only if once Draw() function is called ? Any help on allowed "drawing heirarchy" is appreciated!
    Jay Shah.

  2. #2
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    146

    Re: About Draw() function

    Try to do all your drawing in Draw. Framework calls your Draw implementation when you call DrawNow or DrawDeferred. Before your Draw is called, framework does some initialization ( e.g. activates the graphics context for you), without you cannot draw. That's why your crashes.

    It is possible to draw outside Draw, but then you need to take care of activating and deactivating the graphics context yourself. Also, remember that you must make sure the graphics context is activated only once and deactivated when you do not need it anymore. If you try to activate the gc a second time and gc is already actived, you will have a panic.

    So it is better to leave all drawing to Draw and let the framework worry about the rest.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: About Draw() function

    Thanks for the reply...
    But i have done as following:

    myContainer::ConstructL()
    {
    ...
    ActivateL();
    DrawNow();
    subDraw();
    }

    myContaiiner::Draw()
    {
    subDraw();
    }

    Now if I comment out subDraw() in ConstructL()the code works and if I put subDraw in constructL() even after DrawNow(),... it does not work. I cant understand this behaviour of the Series 60 UICON architecure... [:(]
    Jay Shah.

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

    Re: About Draw() function

    Try http://wiki.forum.nokia.com/index.ph...ded_panic_code instead of writing "crashes".

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: About Draw() function

    Hey thanks a lot for such a wonderful piece of Information... Never knew about Extended Panic Codes.

    The panic I got WSERV 9 which means graphics context was not active.
    Then also the question is same. If it can work in call to DrawNow() then why not in subDraw() at the same time ?
    Jay Shah.

  6. #6
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: About Draw() function

    If the call to DrawNow translates into

    DrawNow()
    {
    - prepare draw
    - call draw -> call subdraw
    - end draw
    }

    then obviously your call directly to subdraw does not execute in the same context.

    The SDK should have enough information about the graphic context activation if you want to understand what "prepare draw" and "end draw" stand for above.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: About Draw() function

    Thanks a lot for the information. Actually did not know that DrawNow() function does the work of activating GraphicsContext. Now i can draw from subDraw() by explicitely activating GraphicsContext.

    The one thing that confuses is that is there anyway by which we can come to know that a graphics context is already activated or not ?
    Jay Shah.

  8. #8
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    146

    Re: About Draw() function

    Quote Originally Posted by jayshahce View Post
    The one thing that confuses is that is there anyway by which we can come to know that a graphics context is already activated or not ?
    It is activated by the framework before Draw is called, and deactivated after calling Draw. Otherwise, it is activated only if you activate it in your code. And then you should know if it is active or not.

Similar Threads

  1. Draw() function not called!
    By sanjayrajwani in forum Symbian
    Replies: 3
    Last Post: 2008-05-09, 09:54
  2. Slide show of bitmaps in draw function
    By emeoh254 in forum Symbian
    Replies: 4
    Last Post: 2007-03-05, 07:35
  3. Display a bitmap outside of a Draw function
    By mngassa in forum Symbian
    Replies: 5
    Last Post: 2003-09-26, 08:47
  4. Cannot compile SDK's examples for 7650 platform...
    By midletsoft in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-08-12, 19:11
  5. Problem with Nokia D211 Linux Drivers
    By fiveam in forum Multimodecards
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

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