maGetScrSize: what does the retured value mean?

3 posts / 0 new
Last post
goodfriend
goodfriend's picture
Offline
Joined: 29 Mar 2010
Posts:
maGetScrSize: what does the retured value mean?

What does the screen size mean?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Getting the Screen Size and Orientation

There are a lot of different screen sizes around now. It used to be that there were two or three common sizes which virtually all phones shared. Now, with so many different aspect ratios it is almost impossible to predict what the screen size and shape will be.

However, it is easy to query a device's screen size from within your application using the maGetScrSize() function:

MAExtent screenSize = maGetScrSize();
int scrWidth = EXTENT_X(screenSize);
int scrHeight = EXTENT_Y(screenSize);

This will give you the height and width of the screen in pixels. To know whether the screen is in landscape or portrait mode, you need to test the sizes:

if(scrWidth > scrHeight)
{
//Landscape mode
}
else
{
//Portrait mode
}

If you want a widget to be a quarter of the screen size, then you can specify it as:

Widget* alertLabel = new Label(0, 0, scrWidth / 2, scrHeight / 2, NULL);

goodfriend
goodfriend's picture
Offline
Joined: 29 Mar 2010
Posts:

OK,thank you!