我用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.
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.
SetTimer(
HWND hWnd, // handle to window
UINT_PTR nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // timer procedure
);
TIMERPROC即为ontimer函数的入口地址
至于消息的获得可以WM_TIMER 和 用 回调函数
//回调函数
procedure timepro(hWnd: HWND; uMsg: UINT; idEvent: UINT; Time: DWORD);
begin
messagebox(form1.Handle,'给分吧!呵呵','提示',mb_ok);
end;
//TIMER定义
settimer(form1.Handle ,1,60000,@timepro);
begin
messagebox(form1.Handle,'给分吧!','提示',mb_ok);
end;
settimer(form1.Handle ,1,60000,@timepro);