如何让最小化 不能看到窗口 但是在状态栏让看到窗口的button呢(100分)

  • 主题发起人 主题发起人 goddy
  • 开始时间 开始时间
G

goddy

Unregistered / Unconfirmed
GUEST, unregistred user!
如何让最小化 不能看到窗口 但是在状态栏让看到窗口的button呢
如我开了一个聊天窗口,然后最小化后不想看到窗口了 只想在状态栏窗口 点一下打开窗口
 
unit Unit1;

interface

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

const
IDI_TRAYICON = WM_USER + 10;
TRAY_CALLBACK = WM_USER + 240;

type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Minimize(Sender: TObject);
private
nTrayIcon : tnotifyicondata;
procedure pNotifyIcon(var msg : TMessage); message TRAY_CALLBACK;
procedure ActiveTrayIcon;
procedure ReleaseTrayIcon;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ActiveTrayIcon;
begin
nTrayIcon.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
nTrayIcon.uID := uint(IDI_TRAYICON);
nTrayIcon.cbSize := SizeOf(tnotifyicondata);
nTrayIcon.uCallbackMessage := TRAY_CALLBACK;
nTrayIcon.Wnd := Handle;
nTrayIcon.hIcon := Application.Icon.Handle;
StrPCopy(nTrayIcon.sztip, Application.Title + '(单击恢复)');
Shell_NotifyIcon(nim_add, @nTrayIcon);
Visible := false;
Application.Minimize;
end;

procedure TForm1.ReleaseTrayIcon;
begin
nTrayIcon.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
nTrayIcon.uID := uint(IDI_TRAYICON);
nTrayIcon.cbSize := SizeOf(tnotifyicondata);
nTrayIcon.uCallbackMessage := TRAY_CALLBACK;
nTrayIcon.Wnd := Handle;
nTrayIcon.hIcon := Application.Icon.Handle;
StrPCopy(nTrayIcon.sztip, Application.Title + '(单击恢复)');
Shell_NotifyIcon(nim_delete, @nTrayIcon);
Visible := True;
Application.Restore;
Application.BringToFront;
end;

procedure TForm1.pNotifyIcon(var msg : TMessage);
begin
if msg.LParam = WM_LBUTTONUP {WM_LBUTTONDBLCLK} then
ReleaseTrayIcon;
end;

procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
ActiveTrayIcon;
end;

end.
 
楼主说的不够清楚,觉得像绕口令。
应该不是要的系统托盘吧。
 
除了这个,很难想象他到底要什么?呵呵
 
ShowWindow(Handle, SW_HIDE); //隐藏主窗体
//隐藏应用程序窗口在任务栏上的显示
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW));
 
后退
顶部