因为控制程序上不能放控件,所以也就是不能直接把Timer这个控件拉到窗体中,那么要想实现这样的功能怎么办能,希望大家帮助!
谢谢!

解决方案 »

  1.   

    SetTimer Function--------------------------------------------------------------------------------The SetTimer function creates a timer with the specified time-out value. SyntaxUINT_PTR SetTimer(          HWND hWnd,
        UINT_PTR nIDEvent,
        UINT uElapse,
        TIMERPROC lpTimerFunc
    );
    ParametershWnd
    [in] Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored. 
    nIDEvent
    [in] Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored. If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. 
    uElapse
    [in] Specifies the time-out value, in milliseconds. 
    Windows NT/2000/XP: If uElapse is greater than 0x7fffffff, the timeout is set to 1.Windows 2000/XP: If uElapse is less than 10, the timeout is set to 10.Windows Server 2003: If uElapse is greater than 0x7fffffff, the timeout is set to 0x7fffffff. lpTimerFunc
    [in] Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter. 
    Return ValueIf the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer. If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.
    ResAn application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER. The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter. The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct. SetTimer can reuse timer IDs in the case where hWnd is NULL. ExampleFor an example, see Creating a Timer.Function InformationHeader Declared in Winuser.h, include Windows.h 
    Import library User32.lib 
    Minimum operating systems Windows 95, Windows NT 3.1 See AlsoTimers Overview, KillTimer, MSG, TimerProc, WM_TIMER--------------------------------------------------------------------------------© 2003 Microsoft Corporation. All rights reserved. 呵呵,绝对对你有用~~adayuer
      

  2.   

    用API函数.先用settimer设置计时器.
    UINT SetTimer(    HWND hWnd, // handle of window for timer messages
        UINT nIDEvent, // timer identifier
        UINT uElapse, // time-out value
        TIMERPROC lpTimerFunc  // address of timer procedure
       );//你可以设置回调函数lpTimerFunc如下.也可以重载WndProc过程.对消息WM_TIMER计时器消息进行处理...VOID CALLBACK TimerProc(    HWND hwnd, // handle of window for timer messages 
        UINT uMsg, // WM_TIMER message
        UINT idEvent, // timer identifier
        DWORD dwTime  // current system time
       );
     
    //用完后杀死TIMER
    BOOL KillTimer(    HWND hWnd, // handle of window that installed timer
        UINT uIDEvent  // timer identifier
       );
      

  3.   

    对第二个参数的设置可参看<<WINDOWS 程序设计>>一书.一般设为 1 就行了.
      

  4.   

    还有一种方法要方便一些:写一个线程,在线程的执行体中写:
    while True do
    begin
        ....
        aaa();
        ....
        Sleep(1000);
    end;
    这不就实现了每隔1秒执行一次aaa函数了吗。
      

  5.   

    不知constantine(飘遥的安吉儿) 大虾对sleep有何疑问啊?
      

  6.   

    Sleep(1000)不能实现真正的没一秒执行一次的。
    它只是休眠1秒这个功能。如果AAA()函数执行的时间它3秒的话。哪大约是4秒才执行一次AAA函数的。
      

  7.   

    program Project2;uses
      Forms,windows,qdialogs;{$R *.res}begin
      Application.Initialize;
      while true do
        begin
          sleep(1000);
          showmessage('af');
        end;
      Application.Run;
    end.
    这个最简单了,不知道行不行?
      

  8.   

    难道需要在AAA函数还未执行完毕的时候又再执行AAA函数?恕在下愚钝,不知道这样做是否现实啊?
      

  9.   

    用sleep不就是死循环了吗,应该加一个能控制让他BREAK的措施吧