当delphi可执行程序最小化时如何把它放到屏幕右下角有系统时间的那栏里?(20分)

  • 主题发起人 主题发起人 patriot
  • 开始时间 开始时间
P

patriot

Unregistered / Unconfirmed
GUEST, unregistred user!
当delphi可执行程序最小化时如何把它放到屏幕右下角有系统时间的那栏里?
给点代码提示最好了。。。。。
 
托盘程序啊
 
to lanbing1400
能给点代码提示吗?谢了先
 
系统托盘,在网上搜索: delphi 系统托盘
 
给我你的信箱,我给你发个例子
 
用控件实现 很简单 不要编程
TrayIcon或RXLIB中也有
 
d6f9b@sina.com
谢谢了
 
uses ShellAPI;
用Shell_NotifyIcon()函数,其他的参考Windows API的帮助就行了
 
发过去了,请查收
 
var
NIM_Data:NOTIFYICONDATAA;
begin

NIM_Data.cbSize := sizeof(NIM_Data);
NIM_Data.Wnd := Self.Handle;
NIM_Data.uID := 100;
NIM_Data.uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
NIM_Data.uCallbackMessage := WM_SHELLMENUCLICK;
NIM_Data.szTip := '信息发送工具';
NIM_Data.hIcon := LoadIcon(hInstance,'SHOW_ICON');
Shell_NotifyIconA(NIM_ADD,@NIM_Data);
end;
 
to lanbing1400
不行啊,解压出错阿。。。
 
自已看吧
unit TrayIcon;

interface

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

type
TTrayIcon = class(TCustomControl)
private
{ Private declarations }
FNotificationHandle:HWnd;
FTrayIcon:TIcon;
FShowHint:boolean;
FHint:string;
FActive:boolean;
FCurrentlyActive:boolean;
FOnDblClick:TNotifyEvent;
FPopupMenu:TPopupMenu;
procedure NotificationWndProc(var Message:TMessage);
procedure SetShowHint(const Value:boolean);
procedure SetHint(const Value:string);
procedure SetTrayIcon(const Value:TIcon);
procedure SetActive(const Value:boolean);
procedure SetPopupMenu(const Value:TPopupMenu);
protected
{ Protected declarations }
procedure DoDblClick;
procedure Loaded;override;
procedure OnAppMinimize(Sender:TObject);
function SendTrayMessage(AMessage:DWORD):boolean;
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure RemoveTrayIcon;
procedure RestoreApp;
procedure ShowTrayIcon;
procedure RemoveFromTaskbar;
procedure ShowInTaskbar;
published
{ Published declarations }
property Active:boolean read FActive write SetActive;
property Hint:string read FHint write SetHint;
property OnDblClick:TNotifyEvent read FOnDblClick write FOnDblClick;
property PopupMenu:TPopupMenu read FPopupMenu write SetPopupMenu;
property ShowHint:boolean read FShowHint write SetShowHint;
property TrayIcon:TIcon read FTrayIcon write SetTrayIcon;
end;

procedure Register;

implementation

const
ID_TRAYICON=1;
UWM_TRAYICON=WM_USER+1;

procedure Register;
begin
RegisterComponents('System', [TTrayIcon]);
end;

{ TTrayIcon }

constructor TTrayIcon.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FNotificationHandle:=AllocateHWnd(NotificationWndProc);
FTrayIcon:=TIcon.Create;
Application.OnMinimize:=OnAppMinimize;
end;

destructor TTrayIcon.Destroy;
begin
if FCurrentlyActive then
RemoveTrayIcon;
FTrayIcon.Free;
if FNotificationHandle<>0 then
DeallocateHWnd(FNotificationHandle);
inherited Destroy;
end;

procedure TTrayIcon.DoDblClick;
begin
if Assigned(OnDblClick) then
OnDblClick(self);
end;

procedure TTrayIcon.Loaded;
begin
inherited Loaded;
if not(csDesigning in ComponentState) then begin
if FTrayIcon.handle=0 then
FTrayIcon.Assign(application.Icon);
end;
SetTrayIcon(FTrayIcon);
if FActive then
ShowTrayIcon;
end;

procedure TTrayIcon.NotificationWndProc(var Message: TMessage);
var Pt:TPoint;
begin
if Message.Msg = UWM_TRAYICON then begin
case message.LParam of
WM_LBUTTONDBLCLK:
DoDblClick;
WM_RBUTTONDOWN:
if Assigned(FPopupMenu) then begin
SetForegroundWindow(FNotificationHandle);
GetCursorPos(Pt);
FPopupMenu.Popup(Pt.X,Pt.Y);
end;
end;
end;
end;

procedure TTrayIcon.OnAppMinimize(Sender: TObject);
begin
if FCurrentlyActive then
RemoveFromTaskbar;
end;

procedure TTrayIcon.RemoveFromTaskbar;
begin
if not(csDesigning in ComponentState) then begin
ShowWindow(Application.Handle,SW_HIDE);
ShowWindow(application.MainForm.Handle,SW_HIDE);
end;
end;

procedure TTrayIcon.RemoveTrayIcon;
begin
if FCurrentlyActive then
if SendTrayMessage(NIM_DELETE) then begin
FCurrentlyActive:=false;
ShowInTaskbar;
end;
end;

procedure TTrayIcon.RestoreApp;
begin
ShowInTaskbar;
SetForegroundWindow(Application.MainForm.Handle);
end;

function TTrayIcon.SendTrayMessage(AMessage: DWORD): boolean;
var Flags:Integer;
NotifyIconData:TNotifyIconData;
begin
Result:=true;
if csDesigning in ComponentState then
exit;
Flags:=NIF_MESSAGE OR NIF_ICON;
if FShowHint then
Flags:=Flags or NIF_TIP;
FillChar(NotifyIconData,Sizeof(NotifyIconData),0);
with NotifyIconData do begin
cbSize:=Sizeof(TNotifyiconData);
Wnd:=FNotificationHandle;
uID:=ID_TRAYICON;
uFlags:=Flags;
uCallBackMessage:=UWM_TRAYICON;
hIcon:=FTrayIcon.Handle;
strcopy(szTip,Pchar(FHint));
end;
result:=Shell_NotifyIcon(AMessage,@NotifyIconData);
end;

procedure TTrayIcon.SetActive(const Value: boolean);
begin
FActive:=Value;
if FActive then
ShowTrayIcon
else
RemoveTrayIcon;
end;

procedure TTrayIcon.SetHint(const Value: string);
begin
FHint:=Value;
SendTrayMessage(NIM_MODIFY);
end;

procedure TTrayIcon.SetPopupMenu(const Value: TPopupMenu);
begin
FPopupMenu:=value;
end;

procedure TTrayIcon.SetShowHint(const Value: boolean);
begin
FShowHint:=value;
SendTrayMessage(NIM_MODIFY);
end;

procedure TTrayIcon.SetTrayIcon(const Value: TIcon);
begin
FTrayIcon.Assign(value);
SendTrayMessage(NIM_MODIFY);
end;

procedure TTrayIcon.ShowInTaskbar;
begin
if not(csDesigning in ComponentState) then begin
if Application.MainForm <> nil then
ShowWindow(application.MainForm.Handle,SW_SHOWNORMAL);
ShowWindow(application.Handle,SW_SHOWNORMAL);
end;
end;

procedure TTrayIcon.ShowTrayIcon;
begin
if SendTrayMessage(NIM_ADD) then
FCurrentlyActive:=true;
end;

end.
 
你的WINRAR版本不够。下一个3.0版的
 
用api shell_notifyicon
或者,简单点,用rxlib控件
一拖即可
 
去下载一个免费控件吧。

什么都有了。。托盘动画。数字显示呀。等等。。。
 
分两部分来操作
1、隐藏任务栏上的应用程序;
2、实现tray图标;
 
呵呵,那请问,隐藏任务栏的那段程序代码怎么写?
我的那个能够实现tray 同时也能够隐藏 任务栏,但是在 还是不能够完全隐藏
就有点象qq 那样最小化的时候 出的问题
谢谢,最好能够给出全部源代码,谢谢!~~~
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
601
import
I
后退
顶部