计时器设置为10ms响应一次
运算只是简单几句:
procedure timeproc(utimerid, umessage: uint; dwuser, dw1, dw2: dword) stdcall;
var
strmin,strsec,strpercent:string;
begin           //计时过程,相当于timer里的ontimer  Count:=Count+1;
  hr:=Count div 360000;
  min:=Count div 6000;
  sec:=(Count div 100) mod 60;
  percent:=Count mod 100; form1.hour.Caption:=inttostr(hr);
 //显示minute
 if min<10 then
   strmin:='0'+inttostr(min)
 else
   strmin:=inttostr(min);
 form1.minute.Caption:=strmin;
 //显示second
 if sec<10 then
  strsec:='0'+inttostr(sec)
 else
  strsec:=inttostr(sec);
 form1.second.Caption:=strsec;
 //显示percent
 if percent<10 then
  strpercent:='0'+inttostr(percent)
 else
  strpercent:=inttostr(percent);
 form1.percent.Caption:=strpercent; 
    Application.ProcessMessages;end;几个label的字体随着窗口大小改变而改变
最大化时label上的font为 form.width div 8当同时打开四个程序以上就会出现系统边满,显示不正常,label刷新不及时,有时候会在screen上显示label的内容...
甚至会弹出 acess read adress /write adress等等...开一个窗口不会有事...

解决方案 »

  1.   

    在绝大多数时间里,都不需要进行:
      hr:=Count div 360000;
      min:=Count div 6000;
    这个操作,更不需要做form1.minute.Caption:=strmin;这类的操作
    改进...
    procedure timeproc(utimerid, umessage: uint; dwuser, dw1, dw2: dword) stdcall;
    var
    strmin,strsec,strpercent:string;
    begin           //计时过程,相当于timer里的ontimer  percent:=percent+1;
     if percent=100 then
        begin
            percent:=0;
            form1.percent.Caption:='00';
            sec:=sec+1;
            if sec=60 then
                begin
                    sec:=0;
                    form1.second.Caption:='00';
                    min:=min+1;
                    if min=60 then
                        begin
                            min:=0;
                            form1.minute.Caption:='00';
                            hr:=hr+1;
                            form1.hour.Caption:=inttostr(hr);
                        end
                    else
                        begin
                            //显示minute
                            if min<10 then
                                strmin:='0'+inttostr(min)
                            else
                                strmin:=inttostr(min);
                            form1.minute.Caption:=strmin;
                        end;
                end
            else
                begin
                    //显示second
                    if sec<10 then
                        strsec:='0'+inttostr(sec)
                    else
                        strsec:=inttostr(sec);
                    form1.second.Caption:=strsec;
                end;
        end
     else
        begin
            if percent<10 then
                strpercent:='0'+inttostr(percent)
            else
                strpercent:=inttostr(percent);
            form1.percent.Caption:=strpercent;
       end;
    end;通过这么繁琐的一堆判断,效果有改善,但是不大,打开四个窗口之后还是很慢..我将每10ms响应一次改为100ms响应一次,程序基本上就不怎么耗cpu,运行还很流畅
    是不是10ms就没办法再改进了?