2014-01-19 3 views
2

C# 데스크톱 응용 프로그램을 개발 중입니다. 내 모든 열린 창문이 갑자기 나타나기를 바란다. (Alt + Tab) 5 분마다 발생한다. 나는 여기서 몇 가지 질문을 보았다. 그들은 타이머를 사용하여 작업을 제안하지만 최소화 된 창은 어떻게 갑니까?Xth 분마다 창 최대화

답변

2

다음은 실제로 작업 할 수있는 기본적인 예입니다.

  1. 먼저 타이머를 만듭니다.

  2. 타이머가 작동 할 때 실행되는 함수를 만듭니다.

  3. 그런 다음 틱 할 때마다 실행할 이벤트를 추가하십시오. 그리고 당신의 기능을 연결하십시오.

  4. 5 분이 지나면 그 기능을 점검하십시오. 그렇다면, 에게 창 여기

    public partial class TimerForm : Form 
    { 
        Timer timer = new Timer(); 
        Label label = new Label(); 
    
        public TimerForm() 
        { 
         InitializeComponent(); 
    
         timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called 
         timer.Interval = (1000) * (1);    // Timer will tick evert second 
         timer.Enabled = true;      // Enable the timer 
         timer.Start();        // Start the timer 
        } 
    
        void timer_Tick(object sender, EventArgs e) 
        { 
          // HERE you check if five minutes have passed or whatever you like! 
    
          // Then you do this on your window. 
          this.WindowState = FormWindowState.Maximized; 
        } 
    } 
    
0

을 극대화하는 완벽한 솔루션

public partial class Form1 : Form 
{ 
    int formCount = 0; 
    int X = 10; 
    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); 

    public Form1() 
    { 
     InitializeComponent(); 

     timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called 
     timer.Interval = (1000) * X;    // Timer will tick evert second 
     timer.Enabled = true;      // Enable the timer 
     timer.Start(); 
    } 

    void timer_Tick(object sender, EventArgs e) 
    { 
     FormCollection fc = new FormCollection(); 
     fc = Application.OpenForms; 

     foreach (Form Z in fc) 
     { 
      X = X + 5; 
      formCount++; 
      if (formCount == fc.Count) 
       X = 5; 

      Z.TopMost = true; 
      Z.WindowState = FormWindowState.Normal; 
      System.Threading.Thread.Sleep(5000); 
     } 
    } 
} 
에게 있습니다