469,362 Members | 2,540 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

Create a slide show of multiple forms

Hi!

I have a requirement where I need to display multiple forms one after
the other like a slide show. These are in the same application.

Basicall on selection of a menu item it should start then clicking on
any of th screens or tray icon it should stop.

I tried the following (To start it on pressing escape on form1 and end
it when escape is again
pressed on form1):

this.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.Form1_Ke yDown);

In the handler I wrote the following code :

private void Form1_KeyDown(object
sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Escape)
{
if(null == thread)
{
currentSize = this.Size;
ThreadStart delegateThread = new
ThreadStart(this.KioskDisplay);
thread = new Thread(delegateThread);
running = true;
thread.Start();
}
else
{
running = false;
//thread.Abort();
thread.Join();
thread = null;
this.Show();
}
}
}

The code for the slide show function :

private void KioskDisplay()
{
ArrayList forms = new ArrayList();
forms.Add(this);
forms.Add(form2);
forms.Add(form3);
forms.Add(form4);
this.Hide();
form2.Hide();
form3.Hide();
form4.Hide();

Form currentForm = null;
for(int i = 0;true == running; i++)
{
if(null != currentForm)
currentForm.Hide();
currentForm = (Form)forms[i%4];
currentForm.Show();
currentForm.Refresh();
currentForm.Focus();
System.Threading.Thread.Sleep(2000);
}
}

My Question : 1. Is there a better way of doing it.
2. In my case once I do escape it starts, on
second escape it stops, but
pressing the escape again shows only form1
and other forms don't appear
in the loop only form1 comes and hides others
are not shown.

Any pointers to it will be highly appreciated.

regards,
Rajat Jain

Feb 2 '06 #1
0 4498

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Michael Burtenshaw | last post: by
7 posts views Thread by Rudy | last post: by
reply views Thread by Ed Sproull [MSFT] | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.