如何创建一个没有窗体的小程序,在这个程序中还须用到一个timer,并且设置好timer的属性和事件?

解决方案 »

  1.   

    这容易啊,全用API好了,很小的
      

  2.   

    用SDK方式写程序,全部调用API函数.
      

  3.   

    就用一个dpr文件!
    在它里面定义TTimer控件就行了 .
      

  4.   

    用API!
    直接写WM_TIMER消息!——方法一!
    写TIMER回调函数!——方法二!
      

  5.   

    在.dpr文件中加入以下程序:
    Application.ShowMainform:=false;
    当然如果你想程序很小的话可以用AsPack等软件压缩。
    我认为这很简单
      

  6.   

    新建一个控制台(console)工程,然后在里面USES段加入ttimer的单元文件。
    就可以使用了。当然,以上各位用API也是一个不错的办法,效率会更高。
      

  7.   

    program  first;  
     
    uses    Windows,Messages;  
     
    function  AppWindowProc(  
           hWnd:HWND;  
           uMsg:UINT;  
           wParam:WPARAM;  
           lParam:LPARAM):LRESULT;  stdcall;  
    begin  
       Result  :=  0;  
       case  uMsg  of  
       WM_TIMER:
           begin
             //事件
           end;
       WM_DESTROY:  
           begin  
               PostQuitMessage(0);  
               Exit;  
           end;  
       WM_LBUTTONDOWN:  
           MessageBox(hwnd,  '你已经触发了一个消息,恭喜你!','Billy.Chen的测试',MB_ICONINFORMATION);  
       end;  
       Result:=DefWindowProc(hWnd,  uMsg,  wParam,  lParam);  
    end;  
     
    var  
       wcfirst:  TWndClass;  
       hWnd:  Integer;  
       MSG:  TMsg;  
    begin  
       wcfirst.style  :=  CS_VREDRAW  or  CS_HREDRAW;  
       wcfirst.lpfnWndProc  :=  @AppWindowProc;  
       wcfirst.cbClsExtra  :=  0;  
       wcfirst.cbWndExtra  :=  0;  
       wcfirst.hInstance  :=  HInstance;  
       wcfirst.hIcon  :=  LoadIcon(0,  IDI_APPLICATION);  
       wcfirst.hCursor  :=  LoadCursor(0,  IDC_ARROW);  
       wcfirst.hbrBackground  :=  (COLOR_BTNFACE+1);  
       wcfirst.lpszMenuName  :=  nil;  
       wcfirst.lpszClassName  :=  'MyTest';  
       if  RegisterClass(wcfirst)=0  then  Exit;  
       hWnd  :=  CreateWindow(  
           wcfirst.lpszClassName,  
           'Billy.Chen的SDK/API测试!',  
           WS_OVERLAPPEDWINDOW,  
           Integer(CW_USEDEFAULT),  
           Integer(CW_USEDEFAULT),  
           Integer(CW_USEDEFAULT),  
           Integer(CW_USEDEFAULT),  
           0,  
           0,  
           HInstance,  
           nil);  
       if  hWnd=0  then  Exit;  
       ShowWindow(hWnd,  SW_SHOWNORMAL);  
       while  GetMessage(MSG,  0,  0,  0)  do  
       begin  
           TranslateMessage(MSG);  
           DispatchMessage(MSG);  
       end;  
    end.