Autor Beitrag
MysteryEskimo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34

WIN Xp
Visual C# Studio 2005
BeitragVerfasst: So 17.06.07 13:16 
ich wollte ein Programm machen, bei dem man auf ein weißes Feld(PictureBox) klicken muss, während es sich bewegt:
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
System.Windows.Forms.Timer t;

void Form1_KeyDown(object sender, KeyEventArgs e)
        {

            t = new System.Windows.Forms.Timer();
            t.Interval = 20;
            t.Tick += new EventHandler(pbBewegen);
            t.Start();
        }

private void pbBewegen(object sender, EventArgs e)
        {
            
            t.Stop();
            
            Random r = new Random();
           int hoehe = r.Next(1240);
           for (int i = 5; i < 245; i++)
           { pictureBox1.Location = new Point(i, hoehe);
           Thread.Sleep(10);
           }
           t.Start();
        }

 private void pictureBox1_Click(object sender, EventArgs e)
        {
            
            MessageBox.Show("Treffer!");
            
        }


Aber dann muss man warten bis pbBewegen() fertig ist bis ein Klick wirkung erzielt!
Hat jemand eine Idee?
r2c2
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 324
Erhaltene Danke: 2

Linux

BeitragVerfasst: So 17.06.07 14:24 
Application.DoEvents(); + F1
sollte helfen...

oder natürlich: Das Bewegen in nem Timer machen...

mfg

Christian

_________________
Kaum macht man's richtig, schon klappts!