如何在程序启动时最小化到任务栏没有图标,(不要托盘的那种)(20分)

  • 主题发起人 主题发起人 wp231957
  • 开始时间 开始时间
W

wp231957

Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下代码无效,开机启动后,主窗口仍然在桌面显示

procedure TForm1.FormCreate(Sender: TObject);
var
reg:tregistry;
local:string;
begin
Application.Minimize ;
showwindow(form1.handle,SW_HIDE);
showWindow(Application.Handle ,SW_HIDE);

local:=Application.ExeName;
reg:=tregistry.Create ;
reg.RootKey :=hkey_local_machine;
reg.OpenKey('software/microsoft/windows/currentversion/run',false);
reg.WriteString('userinit',local);
reg.Free ;

EnableWheelHook;
end;
 
Application.Minimize ;//这个不行,用下面那个
postmessage(handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
ApplicationEvents1: TApplicationEvents;
private
procedure AppMessage(var Msg: TWMSYSCOMMAND); message WM_Syscommand;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AppMessage(var Msg: TWMSYSCOMMAND);
begin
if msg.CmdType = sc_minimize then
Begin
inherited;
Hide;
end;
end;

end.
 
来自:angellover, 时间:2006-11-7 8:31:34, ID:3616362
Application.Minimize ;//这个不行,用下面那个
postmessage(handle,WM_SYSCOMMAND,SC_MINIMIZE,0);

这样不行,确实最小化了,但是到任务栏,我的要求是任务栏里也不能有
 
在OnCreate中
SetWindowLong(application.Handle,GWL_EXSTYLE,GetWindowLong(application.Handle,GWL_EXSTYLE) or
WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
 
postmessage(handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
SetWindowLong(application.handle,gwl_exstyle,ws_ex_toolwindow);//加上这句
 
都分完分了,怎么没揭贴
 
后退
顶部