| procedure TForm1.FormCreate(Sender: TObject); begin SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end; |
在程序运行的初期,首先激活窗体FormCreate()过程中的代码,通过SetWindowLong (Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW)这条语句就可以实现从系统任务条上隐藏本程序的功能。
程序代码如下:
| unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end; end. |
保存文件,然后按F9键运行程序,程序运行结果如图1所示。
![]() 程序运行结果图 |
本实例是演示如何使程序不在系统任务条上显示,其实充分利用SetWindowLong函数的功能,还可以对设置程序的很多额外风格。
0
顶一下0
埋一下引用地址:




