怎么让程序不在任务栏上显示??(50分)

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

wingkk

Unregistered / Unconfirmed
GUEST, unregistred user!
或者让程序的图标缩到系统托盘区,应该怎么做啊????
 
整个界面全屏不就得了
 
举个例子,直接用API的,当然你也可以用控件。
unit TrayIcon;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus,shellapi;

type
//----------------------------------------------------------------------
PNotifyIconData = ^TNotifyIconDataA;
TNotifyIconDataA = record
cbSize : DWORD;
Wnd : HWND;
uID : UINT;
uFlags : UINT;
uCallbackMessage : UINT;
hIcon : HICON;
szTip : array [0..63] of AnsiChar;
end;
//----------------------------------------------------------------------
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
open1: TMenuItem;
close1: TMenuItem;
N1: TMenuItem;
about1: TMenuItem;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure open1Click(Sender: TObject);
procedure close1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
//-------------------------------------------------------------
IconData: TNotifyIconData;
procedure ShowIcon;
procedure IconOnClick(var message:TMessage); message WM_USER+1;
Procedure WMSysCommand(Var message : TMessage) ; Message WM_SYSCOMMAND ;
//-------------------------------------------------------------
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.IconOnClick( var message: Tmessage);
var p : TPoint;
begin
if (message.lParam = WM_LBUTTONDOWN) then
begin
ShowWindow(Handle, SW_SHOW );
end;

if (message.lParam = WM_RBUTTONDOWN) then
begin
GetCursorPos(p);
popupmenu1.Popup( p.x ,p.y );
end;
end;

Procedure TForm1.WMSysCommand(Var Message : TMessage) ;
begin

if (Message.WParam = SC_MINIMIZE) then
begin
ShowIcon;
end
else
Inherited;

end;

procedure TForm1.ShowIcon;
begin
IconData.cbSize := SizeOf( IconData );
IconData.Wnd := Handle;
IconData.uID := 1;
IconData.uFlags := NIF_ICON
or NIF_MESSAGE or NIF_TIP;
IconData.uCallBackMessage := WM_USER+1;
IconData.hIcon := application.Icon.Handle;
IconData.szTip := 'LANChat';
Shell_NotifyIcon( NIM_ADD, @IconData );
ShowWindow(Handle, SW_HIDE);
hide;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon( NIM_DELETE, @IconData );
end;

procedure TForm1.open1Click(Sender: TObject);
begin
Form1.Show;
end;

procedure TForm1.close1Click(Sender: TObject);
begin
Form1.close;
end;

procedure TForm1.FormShow(Sender: TObject);
begin

showwindow(application.handle,sw_hide);


end;

procedure TForm1.FormCreate(Sender: TObject);
begin
showicon;
end;

end.
 
有点长,看不太明白!!!能讲一下吗?????
 
我来一段:
在form1的type里声明过程。
procedure AppMinimize(Sender: TObject);
application.
implementation部分
procedure Tform1.AppMinimize(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
SysTray1.Active := true;
end;
可以在oncreate里写,也可以随意。
form1.windowstate:= wsminimized;
application.Minimize;
application.OnMinimize :=AppMinimize;
 
如果你不想研究具体内容,就直接用控件好了。
TCoolTrayIcon
在www.playicq.com有下载
 
后退
顶部