rt

解决方案 »

  1.   

    program ***initialization 
    sleep(1000)   //1秒  更改里面的参数改变延长时间
    动态创建窗体
    加载
    end;
      

  2.   

    我是说系统空闲onIdle 30秒的时候
      

  3.   

    ///FileName:IdleTimer.Pasunit IdleTimer;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ExtCtrls;typeTIdleTimer = class(TTimer)privatefunction GetSnooze: Longint;procedure SetSnooze(const Value: Longint);{ Private declarations }protected{ Protected declarations }public{ Public declarations }constructor Create(AOwner:TComponent);override;destructor Destroy;override;property Snooze:Longint read GetSnooze write SetSnooze;published{ Published declarations }end;procedure Register;implementationvarInstances:integer;ElapsedTime:Longint;whKeyBoard,whMouse:HHook;procedure Register;beginRegisterComponents('System', [TIdleTimer]);end;{ TIdleTimer }function MouseHookCallBack(Code:integer;Msg:lParam;MouseHook:wParam):DWORD;stdcall;beginif Code>=0 then ElapsedTime :=GetTickCount;Result := CallNextHookEx(whMouse,Code,Msg,MouseHook);end;function KeyBoardCallBack(Code:integer;Msg:word;KeyBoardHook:Longint):LongInt;stdcall;beginif Code>=0 then ElapsedTime :=GetTickCount;Result := CallNextHookEx(whKeyBoard,Code,Msg,KeyBoardHook);end;constructor TIdleTimer.Create(AOwner: TComponent);function GetModuleHandleFromInstance:THandle;vars:array[0..512] of char;beginGetModuleFileName(HInstance,s,SizeOf(s)-1);Result :=GetModuleHandle(s);end;begininherited Create(AOwner);Inc(Instances);if Instances =1 then beginElapsedTime :=GetTickCount;whMouse := SetWindowsHookEx(WH_MOUSE,@MouseHookCallback,GetModuleHandleFromInstance,0);whKeyBoard :=SetWindowsHookEx(WH_KEYBOARD,@KeyBoardCallBack,GetModuleHandleFromInstance,0);end;end;destructor TIdleTimer.Destroy;beginDec(Instances);if Instances =0 then beginUnhookWindowsHookEx(whKeyBoard);UnhookWindowsHookEx(whMouse);end;inherited;end;function TIdleTimer.GetSnooze: Longint;beginResult:= GetTickCount - ElapsedTime;end;procedure TIdleTimer.SetSnooze(const Value: Longint);beginElapsedTime := GetTickCount + Value;end;end.用法:
    if IdleTimer1.Snooze>30000 then创建和启动你的form2窗体强烈要求楼主加分.不只值20分吧?:-)
      

  4.   

    项目加入pas文件,
    procedure TForm1.FormCreate(Sender: TObject);
    var
       IdleTimer1:TIdleTimer;
    begin
         IdleTimer1:=TIdleTimer.Create(self);
         if IdleTimer1.Snooze>3000 then
         Form2.Show;
    end;不行啊,请指教,成功加分!!!
      

  5.   

    好招,干净利索,楼主你的用法有问题。
    当然,你也可以直接放置一个TIdleTimer组件在Form1上来代替下面的声明。var
      I: TIdleTimer;procedure TForm1.FormCreate(Sender: TObject);
    begin
      I := TIdleTimer.Create(Self);
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      I.Free;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    //这个普通的Timer可以设置为Interval=1000
    begin
      if I.Snooze > 30000 then //30秒
        Form2.Show;
    end;
      

  6.   

    大哥阿,不管空闲不空闲一到时间就show阿,而且之后关了还出来!!!
    我加分!!!帮我解决阿,高手!
      

  7.   

    csouth(金子)  代码 10分
    cnsuyong(小可) 讲解 10分
    只不过漏掉了 置回 I.Snooze:=0;
    谢谢二位!!!
      

  8.   

    var
      I: TIdleTimer;procedure TForm1.FormCreate(Sender: TObject);
    begin
      I := TIdleTimer.Create(Self);
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      I.Free;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    //这个普通的Timer可以设置为Interval=1000
    begin
      if I.Snooze > 30000 then //30秒
      begin
        Form2.Show;
        I.Enabled := false;//而且之后关了不出来
      end;
    end;
      

  9.   

    to: King_Dragon(代码虫子) 
      
    看过你的代码,好象有问题哦---------不要扔砖哦.
    因为你的代码没有判断是否是系统空闲!!!!!!!!!!!!!!!