Connecting Tech Pros Worldwide Forums | Help | Site Map

how create Orientation-Awareness window mobile application?

Newbie
 
Join Date: Sep 2009
Posts: 21
#1: Oct 10 '09
hi,
i am struggling to develop screen orientation awareness application. to solve
this problem a have create two function portrait() and landscape() both function set the size and location of control when form re size i call this function on form resize event.
problem is taht when form is resize then it call the function more then one time.
and take more time to execute.
what is reason behind this behavior i don't know.
please help me.
below some code which i am using
Expand|Select|Wrap|Line Numbers
  1.  public void portrait()
  2.         {
  3.             pnlmenu.Size = new Size((frrm.ClientRectangle.Width * 88 / 100), (frrm.ClientRectangle.Height * 27 / 100));
  4.         }
  5.         public void landscap()
  6.         {
  7.             pnlmenu.Size = new Size((frrm.ClientRectangle.Width * 88 / 100), (frrm.ClientRectangle.Height * 27 / 100));
  8.  
  9.  
  10.         }
  11.         private void Form_Resize(object sender, EventArgs e)
  12.         {
  13.  if (Screen.PrimaryScreen.Bounds.Height > 
  14.         Screen.PrimaryScreen.Bounds.Width) Portrait();
  15.     else Landscape();
  16.  
  17.  
  18.  
  19.         }
  20.  
please help me why this function called one then more time at atime when function is resized.

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Oct 12 '09

re: how create Orientation-Awareness window mobile application?


Changing the Size property of a form triggers the ReSize event.
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#3: Oct 13 '09

re: how create Orientation-Awareness window mobile application?


I always used a 3rd party OAC controls like this:

http://www1.orientationaware.net/downloads.html as they offer a free community edition and give you visual studio designers for both orientations.... saves time in the long run
Newbie
 
Join Date: Sep 2009
Posts: 21
#4: Oct 14 '09

re: how create Orientation-Awareness window mobile application?


It still work same and call the function more time when form is resized.
what is reason behind this behavior i can not understand.
if any one has solution then please help me.
Reply