<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Anthony Wong's Blog : GUI</title><link>http://blogs.msdn.com/anthonywong/archive/tags/GUI/default.aspx</link><description>Tags: GUI</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MessageBox issue</title><link>http://blogs.msdn.com/anthonywong/archive/2006/04/12/575336.aspx</link><pubDate>Thu, 13 Apr 2006 00:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:575336</guid><dc:creator>antwong</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/anthonywong/comments/575336.aspx</comments><wfw:commentRss>http://blogs.msdn.com/anthonywong/commentrss.aspx?PostID=575336</wfw:commentRss><description>&lt;P&gt;&lt;FONT size=2&gt;On NETCF V2, a message box is automatically closed if MessageBox.Show() is called after a form is closed. This is different behavior from NETCF V1 and Desktop (V1/V2).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;To work around the issue, simply call Message.Show() on another thread with codes like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;In the Main() function, add the following lines after Application.Run():&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#008080&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Thread&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; t = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Thread&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;ThreadStart&lt;/FONT&gt;(DoWork));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.Start();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t.Join();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Add the following method to the Form class:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT size=2&gt;static&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; DoWork()&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MessageBox.Show(&lt;FONT color=#800000&gt;"finish"&lt;/FONT&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Cheers,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Anthony Wong [MSFT]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=575336" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/anthonywong/archive/tags/GUI/default.aspx">GUI</category></item><item><title>Splash Screen on Pocket PC</title><link>http://blogs.msdn.com/anthonywong/archive/2005/07/28/444684.aspx</link><pubDate>Fri, 29 Jul 2005 01:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:444684</guid><dc:creator>antwong</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/anthonywong/comments/444684.aspx</comments><wfw:commentRss>http://blogs.msdn.com/anthonywong/commentrss.aspx?PostID=444684</wfw:commentRss><description>&lt;P&gt;Sometimes it would be nice to add a splash screen to your Pocket PC application. You can show your company logo, product title, product logo as well as other information on the splash screen. On .NET Framework, you may use two Application.Run() calls, passing the splash screen form to the first call and the main form to the second call. On .NET Compact Framework, since you cannot do more than one Application.Run() call on one thread, the splash screen form needs to be called by the main form.&amp;nbsp;We are going to&amp;nbsp;illustrate how this can be done in a sample application.&lt;/P&gt;
&lt;P&gt;The application consists of two forms, one for the splash screen and the other for the main form. When the application is run, the splash screen is shown full-screen with&amp;nbsp;the text ".NET Compact Framework" at the center of the screen. After 3 seconds, the splash screen form is closed and the main form is shown.&lt;/P&gt;
&lt;P&gt;Here are the codes for the application:&lt;/P&gt;&lt;PRE&gt;using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

class Form1 : System.Windows.Forms.Form
{
    public Form1()
    {
        this.MinimizeBox = false;
        Form2 form = new Form2();
        form.ShowDialog();
    }

    static void Main()
    {
        Application.Run(new Form1());
    }
}

public class Form2 : System.Windows.Forms.Form
{
    public Form2()
    {
        this.FormBorderStyle = FormBorderStyle.None;
        this.WindowState = FormWindowState.Maximized;
        this.TopMost = true;
        this.BackColor = Color.Green;
        Timer timer = new Timer();
        timer.Interval = 3000;
        timer.Tick += new EventHandler(timer_Tick);
        timer.Enabled = true;
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        StringFormat sf = new StringFormat();
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;
        Graphics g = e.Graphics;
        g.DrawString(".NET Compact Framework", this.Font, new SolidBrush(Color.Blue), Screen.PrimaryScreen.Bounds, sf);
    }

    void timer_Tick(object o, EventArgs e)
    {
        this.Close();
    }
}
&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Anthony&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color=#000000&gt;This posting is provided "AS IS" with no warranties, and confers no rights. &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=444684" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/anthonywong/archive/tags/GUI/default.aspx">GUI</category></item><item><title>Scrolling with Dial Pad on SmartPhone</title><link>http://blogs.msdn.com/anthonywong/archive/2005/05/12/416907.aspx</link><pubDate>Thu, 12 May 2005 13:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:416907</guid><dc:creator>antwong</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/anthonywong/comments/416907.aspx</comments><wfw:commentRss>http://blogs.msdn.com/anthonywong/commentrss.aspx?PostID=416907</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;NETCF V2 adds the AutoScroll feature, showing scrollbars on a form when one of its controls is outside the visible region of the form. To enable auto scrolling, simply set the AutoScroll property of the form to true.&amp;nbsp;To change the visible region of the form, you just need to click the buttons of the scrollbars on a Pocket PC or Windows CE device. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;What about SmartPhone? Most SmartPhones do not have a touch screen, so there needs to be an alternative way to scroll the form. The way to scroll a form on a SmartPhone is to handle the keyboard inputs by providing an event handler to the form's KeyDown event:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;this&lt;/SPAN&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;.KeyDown += &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt;&lt;/FONT&gt; KeyEventHandler(key_Down);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT face="Courier New" color=blue&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000000&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT color=#0000ff&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;private&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; key_Down(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; o, KeyEventArgs e)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ((e.KeyCode == System.Windows.Forms.Keys.Up))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;.AutoScrollPosition = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; Point(&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.AutoScrollPosition.X, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.AutoScrollPosition.Y - 16);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ((e.KeyCode == System.Windows.Forms.Keys.Down))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;.AutoScrollPosition = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; Point(&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.AutoScrollPosition.X, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.AutoScrollPosition.Y + 16);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ((e.KeyCode == System.Windows.Forms.Keys.Left))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;.AutoScrollPosition = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; Point(&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.AutoScrollPosition.X - 16, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.AutoScrollPosition.Y);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; ((e.KeyCode == System.Windows.Forms.Keys.Right))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;.AutoScrollPosition = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; Point(&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.AutoScrollPosition.X + 16, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.AutoScrollPosition.Y);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;FONT face="Courier New" color=blue&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face=Arial color=#000000&gt;This will allow scrolling the form with the dial pad while the form is focused.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face=Arial color=#000000&gt;How about if the form is &lt;EM&gt;not &lt;/EM&gt;focused? Sometimes the control in focus might be a PictureBox object, or a UserControl. In these cases, simply&amp;nbsp;add the event handler we created earlier to the KeyDown event of the control:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;.pb.KeyDown += &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt;&lt;/FONT&gt; KeyEventHandler(key_Down);&lt;/SPAN&gt; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Arial color=#000000&gt;This will provide scrolling with the dial pad while either the form or the control is focused.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial color=#000000&gt;Cheers,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial color=#000000&gt;Anthony&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color=#000000&gt;This posting is provided "AS IS" with no warranties, and confers no rights. &lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=416907" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/anthonywong/archive/tags/GUI/default.aspx">GUI</category></item></channel></rss>