DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: jeff1314
今日帖子: 16
在线用户: 17
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 cxjkx (想飞的菜鸟) ★☆☆☆☆ -
盒子活跃会员
2003/12/5 18:20:35
标题:
请各位指教 浏览:1579
加入我的收藏
楼主: 我要做一个程序,要让他在设置好以后,缩小到显示时间的哪个位置,请问要怎么才能实现,谢谢
----------------------------------------------
-
作者:
男 cjrb (Thinking In 魂) ★☆☆☆☆ -
盒子活跃会员
2003/12/6 0:10:21
1楼: 1.自己写代码
unit Unit1;

interface

{ 记住在uses部分中包括 ShellAPI}

uses

Windows, Messages, SysUtils, Classes,

Graphics, Controls, Forms, Dialogs,

ShellAPI, StdCtrls;

{自定义消息,当小图标捕捉到鼠标事件时Windows向回调函数发送此消息}

{自定义消息,当小图标捕捉到鼠标事件时Windows向回调函数发送此消息}

const MY_MESSAGE = WM_USER + 100;

type

TForm1 = class(TForm)

procedure FormCreate(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure FormPaint(Sender: TObject);

private

procedure OnIconNotify(var Message: TMessage);

message MY_MESSAGE;

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

 

{当小图标捕捉到鼠标事件时进入此过程}

{当小图标捕捉到鼠标事件时进入此过程}

procedure TForm1.OnIconNotify(var Message: TMessage);

const

Busy: Boolean = false;

begin

if not Busy then begin

Busy := true;

if Message.LParam=WM_LBUTTONDOWN then

if Application.MessageBox('Are you sure',

'Exit', MB_YESNO)=IDYES then Close;

Busy := false;

end;

end;

{当主Form建立时通知Windows加入小图标}

procedure TForm1.FormCreate(Sender: TObject);

var

nid: TNotifyIconData;

begin

nid.cbSize := sizeof(nid); // nid变量的字节数

nid.Wnd := Handle; // 主窗口句柄

nid.uID := -1; // 内部标识,可设为任意数

nid.hIcon := Application.Icon.Handle; // 要加入的图标句柄,可任意指?

nid.hIcon := Application.Icon.Handle; // 要加入的图标句柄,可任意指?

nid.szTip := 'This is a test application'; // 提示字符串

nid.uCallbackMessage := MY_MESSAGE; // 回调函数消息

nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?

if not Shell_NotifyIcon(NIM_ADD, @nid) then begin

ShowMessage('Failed!');

Application.Terminate;

end;

{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}

SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

end;

{程序被关闭时通知Windows去掉小图标}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

var

nid: TNotifyIconData;

begin

nid.cbSize := sizeof(nid); // nid变量的字节数

nid.cbSize := sizeof(nid); // nid变量的字节数

nid.uID := -1; //内部标识,与加入小图标时的数一致

nid.Wnd := Handle; //主窗口句柄

Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小图标

Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小图标

end;

{主窗口初始化完毕并显示时将激活Paint重画事件,此时将主窗口隐藏}

procedure TForm1.FormPaint(Sender: TObject);

begin

Hide;

end;

end.

 

 

  上例中将程序的图标放在任务条右下角,然后隐藏自身,当用户移动鼠标至该图标上时会看到提示字符串,如果单击该图标会出现一个对话框,选择Yes退出程序并清除小图标。


2.用控件,很多都有这功能,如RXLibary里有个。
----------------------------------------------
按此在新窗口浏览图片 充电..........
作者:
男 cxjkx (想飞的菜鸟) ★☆☆☆☆ -
盒子活跃会员
2003/12/6 12:31:43
2楼: 谢谢了哦,我试一下了,呵呵,感谢
----------------------------------------------
-
作者:
女 xiangfei (想飞) ★☆☆☆☆ -
盒子活跃会员
2003/12/6 18:58:10
3楼: 应该这样写:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,shellapi;
const MY_MESSAGE = WM_USER + 100;
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormPaint(Sender: TObject);
  private
procedure OnIconNotify(var Message: TMessage);

message MY_MESSAGE;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.OnIconNotify(var Message: TMessage);

var busy:boolean;

begin
busy:=false;

if not Busy then begin

busy:=true;

if Message.LParam=WM_LBUTTONDOWN then

if Application.MessageBox('Are you sure',

'Exit', MB_YESNO)=IDYES then Close;

Busy := false;

end;

end;
procedure TForm1.FormCreate(Sender: TObject);
var

nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid); // nid变量的字节数

nid.Wnd := Handle; // 主窗口句柄

nid.uID := 1; // 内部标识,可设为任意数

nid.hIcon := Application.Icon.Handle; // 要加入的图标句柄,可任意指?

nid.hIcon := Application.Icon.Handle; // 要加入的图标句柄,可任意指?

nid.szTip := 'This is a test application'; // 提示字符串

nid.uCallbackMessage := MY_MESSAGE; // 回调函数消息

nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?

if not Shell_NotifyIcon(NIM_ADD, @nid) then begin

ShowMessage('Failed!');

Application.Terminate;

end;

{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}

SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var

nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid); // nid变量的字节数

nid.cbSize := sizeof(nid); // nid变量的字节数

nid.uID := 1; //内部标识,与加入小图标时的数一致

nid.Wnd := Handle; //主窗口句柄

Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小图标

Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小图标

end;

procedure TForm1.FormPaint(Sender: TObject);
begin
hide;
end;

end.
----------------------------------------------
想飞的朋友跟我来。。。
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行62.5毫秒 RSS