如何创建一个没有窗体的小程序,在这个程序中还须用到一个timer,并且设置好timer的属性和事件?
解决方案 »
- dxdbgrid多行更改选中的数据
- 谁有ExpressQuantumGrid Suite v5.5的下载,给小弟一份。增100分。
- ==错误处理和动态连接库的问题?===
- Hint 自己提示 问题!!!!!!!!!!!!!
- 请问:求某字段的最大值的代码如何写?在线等…
- FastReport分栏问题?
- 怎样拖放 CheckListBox 里面的Items 调整其内部顺序
- 要去浙江了~~~散分!!!
- 菜鸟的问题:在线等待,欢迎光临!
- Turbo Power 的LockBox控件哪里能下载?
- 简单问题: 用TABLE的findkey查询的结果可否在DBGRID中显示出来???
- 请问如何做一个自己定义纸张大小,打印内容及打印位置
在它里面定义TTimer控件就行了 .
直接写WM_TIMER消息!——方法一!
写TIMER回调函数!——方法二!
Application.ShowMainform:=false;
当然如果你想程序很小的话可以用AsPack等软件压缩。
我认为这很简单
就可以使用了。当然,以上各位用API也是一个不错的办法,效率会更高。
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.