我用API函数建立的窗体,请问如何使用Delphi中的其它控件呢?如何调用它的事件?(比如Timer)整个程序只有一个dpr文件,以下是部分源码,请高手给予解答,分不够可以再给。const AppName ='TFP';
procedure WinMain;
var
Wnd: hWnd; {声明窗口句柄(Handle)变量}
Msg: TMsg; {声明消息变量}
cls: TWndClass; {窗口类变量}
begin
if FindWindow (AppName, Nil) <> 0 then
MessageBox(0,'程序已经运行.','信息',mb_iconquestion);FillChar(cls,sizeof(cls),0);
cls.lpfnWndProc:= @DummyWindowProc;
cls.hInstance:= hInstance;
cls.lpszClassName:= AppName;
RegisterClass (cls);Wnd:=CreateWindow(AppName,Pchar('Form1'),ws_OverlappedWindow,cw_UseDefault,cw_UseDefault,cw_UseDefault,cw_UseDefault,0,0,hInstance, Nil);
if Wnd <> 0 then
begin
ShowWindow(Wnd,sw_Hide);
while GetMessage(Msg,0,0,0) do
begin
TranslateMessage (Msg);
DispatchMessage (Msg);
end;
end;
end;begin
WinMain;
end.

解决方案 »

  1.   

    呵呵为什么非得用DELPHI的TIMER呢?直接用settimer就可以了!
      

  2.   

    如果用其他的东西,直接USERS包含他的单元就可以了!
      

  3.   

    你用API生成窗体的话,只不过要动态生成(用代码)所有对象及它们的事件而已。对于timer这样的控件,ontimer事件只不过是对于settimer的封装。
    SetTimer(
      HWND hWnd,              // handle to window
      UINT_PTR nIDEvent,      // timer identifier
      UINT uElapse,           // time-out value
      TIMERPROC lpTimerFunc   // timer procedure
    );
    TIMERPROC即为ontimer函数的入口地址
      

  4.   

    对!可以用SetTimer
    至于消息的获得可以WM_TIMER 和 用 回调函数
      

  5.   

    最简单的例子:(settimer)
    //回调函数
    procedure timepro(hWnd: HWND; uMsg: UINT; idEvent: UINT; Time: DWORD);
    begin
     messagebox(form1.Handle,'给分吧!呵呵','提示',mb_ok);
    end;
    //TIMER定义
    settimer(form1.Handle ,1,60000,@timepro);
      

  6.   

    procedure timepro(hWnd: HWND; uMsg: UINT; idEvent: UINT; Time: DWORD);
    begin
     messagebox(form1.Handle,'给分吧!','提示',mb_ok);
    end;
    settimer(form1.Handle ,1,60000,@timepro);
      

  7.   

    那使用NMSMTP控件呢,又该如何??