×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    40

    Question How to detect switching from Portrait to Landscape

    Hi All,
    I am running an application on N95.I need to show an information note when the screen view is changed from QVGA Portrait(240*320) to QVGA Landscape(320*240).

    I am using HandleScreenDeviceChangedL()to detect the change in screen view.Futher I'm using enum TAppUiOrientation = type as switch case.
    But while debugging I can see that the type value(shown below) is always EAppUiOrientationUnspecified, so its not entering into the switch cases for EAppUiOrientationPortrait and
    EAppUiOrientationLandscape.

    I'm using the following code:



    void CMyAppUi::HandleScreenDeviceChangedL()
    {
    TAppUiOrientation type;
    type = Orientation();
    //Here the type is always showing EAppUiOrientationUnspecified

    switch(type)
    {
    case EAppUiOrientationPortrait:
    {
    CEikAppUi::HandleScreenDeviceChangedL();
    iAppView->SetRect(ClientRect());
    }
    break;

    case EAppUiOrientationLandscape:
    {
    // Load a string from the resource file and display it
    HBufC* textResource = StringLoader::LoadLC( R_COMMAND1_TEXT );
    CAknInformationNote* informationNote;

    informationNote = new ( ELeave ) CAknInformationNote;

    // Show the information Note with
    // textResource loaded with StringLoader.
    informationNote->ExecuteLD( *textResource );

    // Pop HBuf from CleanUpStack and Destroy it.
    CleanupStack::PopAndDestroy( textResource );
    }
    break;

    default :
    {
    //nope
    }
    }
    }

    Please tell me where I'm going wrong.
    I will apppreciate every reply.Please do reply.

  2. #2
    Nokia Developer Champion
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572

    Re: How to detect switching from Portrait to Landscape

    void CMyCoeControl::HandleResourceChange(TInt aType)
    {
    CCoeControl::HandleResourceChange(aType);

    #ifdef EKA2
    // ADDED FOR SCALABLE UI SUPPORT
    // *****************************
    if ( aType==KEikDynamicLayoutVariantSwitch )
    {
    TRect rect;
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, rect);
    SetRect(rect);
    }
    #endif // #ifdef EKA2
    }

    void CMyCoecontrol::SizeChanged()
    {
    // any code to change size of my components as per new application rect
    }

    hope this helps !

    (See scalable Ui example too )
    Amit Kankani
    Nokia Developer Champion

Similar Threads

  1. Replies: 2
    Last Post: 2007-08-09, 23:20
  2. landscape to portrait switch.
    By ravinder007 in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-03-14, 09:48
  3. Problem switching between portrait and landscape
    By Tatanka.nbr1 in forum Symbian
    Replies: 0
    Last Post: 2006-05-16, 19:00
  4. Nokia N90 Portrait to Landscape Mode
    By alokkumarsingh in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-12-14, 13:24

Posting Permissions

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