选举先进selectTop

来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.
Post Reply
liqi98136
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

选举先进selectTop

Post by liqi98136 »

Code: Select all

import "ecere"



class MyDlg : Window
{
   text = "选举先进";
   background = activeBorder;
   borderStyle = fixed;
   hasClose = true;
   size = { 360, 280 };
   autoCreate = false;

   int s1,s2,s3,s4;
   
   Button button2 
   {      
      this, text = "确认投票", position = { 248, 168 };
      
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         
         int temp; 
         temp=atoi(editBox1.contents);
         switch(temp)
         {
            case 1:
               s1++;
               label5.text=PrintString(s1);
               break;
            case 2:
               s2++;
               label6.text=PrintString(s2);
               break;
            case 3:
               s3++;
               label7.text=PrintString(s3);
               break;
            case 4:
               s4++;
               label8.text=PrintString(s4);
               break;
            default:
               MessageBox{this,type=ok,text="警告",contents="请输入正确的编号"}.Modal();

         }
         editBox1.contents=""; 

         return true;
      }
   };
   Label label11 { this, text = "输入侯选人编号:", size = { 96, 13 }, position = { 64, 168 } };
   EditBox editBox1 { this, text = "editBox1", size = { 30, 19 }, position = { 160, 168 } };
   Button button1 
   {      
      this, text = "评选", position = { 168, 208 };

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         int max,flag;
         char s[255];
         max=s1;
         flag=1;
         sprintf(s,"先进个人是李明,得票为 %d",max);
         if(s2>max)
         {
            max=s2;
            flag=2;
            sprintf(s,"先进个人是王海,得票为 %d",max); 
         }
         if(s3>max)
         {
            max=s3;
            flag=3;
            sprintf(s,"先进个人是张伟,得票为 %d",max);
         }
         if(s4>max)
         {
            max=s4;
            flag=4;
            sprintf(s,"先进个人是赵四,得票为 %d",max); 
         }
         if(s) MessageBox{this,type=ok,text="信息",contents=s}.Modal();

         return true;
      }
   };

   Label label1 { this, text = "1. 李明", position = { 120, 96 } };
   Label label2 { this, text = "2. 王海", position = { 120, 128 } };
   Label label3 { this, text = "3. 张伟", position = { 224, 96 } };
   Label label4 { this, text = "4. 赵四", position = { 224, 128 } };
   Label label5 { this, size = { 16, 13 }, position = { 176, 96 } };
   Label label6 { this, size = { 16, 13 }, position = { 176, 128 } };
   Label label7 { this, size = { 16, 13 }, position = { 280, 96 } };
   Label label8 { this, size = { 20, 13 }, position = { 280, 128 } }; 
   Label label9 { this, text = "选举先进", size = { 100, 29 }, position = { 184, 40 } }; 
   Label label10 { this, text = "===========================", size = { 276, 13 }, position = { 64, 192 } };  

   bool OnCreate(void)
   {

      s1=0,s2=0,s3=0,s4=0;

      label5.text=PrintString(s1);
      label6.text=PrintString(s2);
      label7.text=PrintString(s3);
      label8.text=PrintString(s4);

      return true;
   }
}


class Form1 : Window
{
   text = "例子";
   background = activeBorder;
   borderStyle = sizable;
   hasClose = true;
   size = { 360, 280 };
   anchor = { horz = -55, vert = -47 };

   Button button1
   {
      this, text = "先进评选", position = { 8, 8 };

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {

         myDlg.Modal();
         return true;
      }
   };
   MyDlg myDlg{};
}
Form1 form1 {};
Post Reply