By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Rotate screen

P: n/a
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do?

I only find the code for pocket PC 2003 upgrade.

private void SetOrientation(ScreenOrientation so)
{

// Set the requested orientation.
SystemSettings.ScreenOrientation.Angle0 = so;
this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
}
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi steve,

Try this:

private void Form1_Load(object sender, System.EventArgs e)
{
int scrRectHeight = Screen.PrimaryScreen.Bounds.Height;
int scrRectWidth = Screen.PrimaryScreen.Bounds.Width;

if (scrRectHeight > scrRectWidth)
{
MessageBox.Show("Run in portrait.");
}
else
{
MessageBox.Show("Run in landscape.");
}

Reference:
http://msdn.microsoft.com/library/de...reenorient.asp

Hope it helps. Correct me if i am wrong.
--
Regards,
Chua Wen Ching :)
"steve" wrote:
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do?

I only find the code for pocket PC 2003 upgrade.

private void SetOrientation(ScreenOrientation so)
{

// Set the requested orientation.
SystemSettings.ScreenOrientation.Angle0 = so;
this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
}

Nov 16 '05 #2

P: n/a
Chua Wen,

Thanks for the quick response, my question is how to rotate the tablet pc screen,
not detect the screen is portrait or landscape.

B. RGDS
Steve

"Chua Wen Ching" wrote:
Hi steve,

Try this:

private void Form1_Load(object sender, System.EventArgs e)
{
int scrRectHeight = Screen.PrimaryScreen.Bounds.Height;
int scrRectWidth = Screen.PrimaryScreen.Bounds.Width;

if (scrRectHeight > scrRectWidth)
{
MessageBox.Show("Run in portrait.");
}
else
{
MessageBox.Show("Run in landscape.");
}

Reference:
http://msdn.microsoft.com/library/de...reenorient.asp

Hope it helps. Correct me if i am wrong.
--
Regards,
Chua Wen Ching :)
"steve" wrote:
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do?

I only find the code for pocket PC 2003 upgrade.

private void SetOrientation(ScreenOrientation so)
{

// Set the requested orientation.
SystemSettings.ScreenOrientation.Angle0 = so;
this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
}

Nov 16 '05 #3

P: n/a
Hi steve,

Well since you already have the values of scrRectHeight and scrRectWidth, you can assume it as x an y.

There is a button, when you click, it actually execute this code:

private void button1_Click(object sender, System.EventArgs e)
{
this.ClientSize = new System.Drawing.Size(scrRectWidth, scrRectWidth);
}

You can switch between both, maybe 1 button or separate buttons.

Hope this is what you want! Good Luck again!
--
Regards,
Chua Wen Ching :)
"steve" wrote:
Chua Wen,

Thanks for the quick response, my question is how to rotate the tablet pc screen,
not detect the screen is portrait or landscape.

B. RGDS
Steve

"Chua Wen Ching" wrote:
Hi steve,

Try this:

private void Form1_Load(object sender, System.EventArgs e)
{
int scrRectHeight = Screen.PrimaryScreen.Bounds.Height;
int scrRectWidth = Screen.PrimaryScreen.Bounds.Width;

if (scrRectHeight > scrRectWidth)
{
MessageBox.Show("Run in portrait.");
}
else
{
MessageBox.Show("Run in landscape.");
}

Reference:
http://msdn.microsoft.com/library/de...reenorient.asp

Hope it helps. Correct me if i am wrong.
--
Regards,
Chua Wen Ching :)
"steve" wrote:
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do?

I only find the code for pocket PC 2003 upgrade.

private void SetOrientation(ScreenOrientation so)
{

// Set the requested orientation.
SystemSettings.ScreenOrientation.Angle0 = so;
this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
}

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.