我想在任务栏上显示一个60分或120分的倒计时。格式,就像右下角的时间格式就行,字体是粗体,颜色红或蓝
字号当然越大越好,哪样看得方便。
这个倒计时时间,背景要透明,像屏幕右下角时间哪样。要一直置顶,不能被其它的任务栏按钮所挡住或覆盖掉,最好它可以用属标实现拖动,但不能拖出这个任务栏区?
这个效果要怎么写?
字号当然越大越好,哪样看得方便。
这个倒计时时间,背景要透明,像屏幕右下角时间哪样。要一直置顶,不能被其它的任务栏按钮所挡住或覆盖掉,最好它可以用属标实现拖动,但不能拖出这个任务栏区?
这个效果要怎么写?
只是一个倒计时的提醒程序,觉得放在任务栏中会明显一些。
Come under study
再在窗体的移动事件里监控位置
详细请见 http://www.yecode.net/2010_04_17_107.html
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
HTrayWnd, HReBar, HBtnStar, ReplaceBtnHwnd, HNotifyWnd: HWND;
TrayWndRct, ReBarTct, BtnStarTct, NotifyWndTct: TRect;
procedure SetPosition;
procedure GetTraySize; procedure CreateButton;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
BorderStyle := bsNone;
HTrayWnd := FindWindow('Shell_TrayWnd', nil);
HReBar := FindWindowEx(HTrayWnd, 0, 'ReBarWindow32', nil);
HNotifyWnd := FindWindowEx(HTrayWnd, 0, 'TrayNotifyWnd', nil);
if Win32MajorVersion < 6 then
begin
HBtnStar := FindWindowEx(HTrayWnd, 0, 'Button', nil);
end
else
begin
HBtnStar := FindWindow('Button', nil);
end;
CreateButton;
end;procedure TForm1.GetTraySize;
begin try
if (Windows.GetWindowRect(HReBar, ReBarTct) = false) or (Windows.GetWindowRect(HTrayWnd, TrayWndRct) = false)
or (Windows.GetWindowRect(HBtnStar, BtnStarTct) = false)
or (Windows.GetWindowRect(HNotifyWnd, NotifyWndTct) = false)
then
begin
Application.MessageBox('错误,初始化获取数据失败,程序退出。', Pchar(Application.Title), MB_OK + MB_ICONERROR);
Application.Terminate;
Application.ShowMainForm := False;
end;
except
end;
end;procedure TForm1.SetPosition;
var
BisWidth: Boolean;
begin
try
GetTraySize;
if TrayWndRct.Right - TrayWndRct.Left > TrayWndRct.Bottom - TrayWndRct.Top then //判断人无论是横向还是纵向
BisWidth := True
else
BisWidth := False;
if BisWidth then
begin
MoveWindow(Self.Handle, BtnStarTct.Right + 5, (TrayWndRct.Bottom - TrayWndRct.Top - Self.Height) div 2, 75, 25, true);
MoveWindow(HReBar, 75 + 5 + BtnStarTct.Right + 5, 0, NotifyWndTct.Left - 75 - 10 - BtnStarTct.Right, ReBarTct.Bottom - ReBarTct.Top, True)
end
else
begin
MoveWindow(Self.Handle, (TrayWndRct.Right - TrayWndRct.Left - Self.Width) div 2, BtnStarTct.Bottom + 3, 75, 25, true);
MoveWindow(HReBar, 0, BtnStarTct.Bottom + 25 + 6, ReBarTct.Right - ReBarTct.Left, NotifyWndTct.Top - 6 - 25 - BtnStarTct.Bottom, True);
end;
except
end;
end;procedure TForm1.CreateButton;
begin
try
Self.ParentWindow := HTrayWnd;
Self.Visible := true;
Self.Width := 75;
Self.Height := 25;
Self.Left := -100;
Self.Caption := '';
SetPosition;
except
end;
end;
end.
var
Datestring: string;
begin
SetPosition;
datestring := TimeToStr(Now);
Canvas.TextOut(0, 0, datestring);
end; SetPosition; 里面是调整位置的,你自己去调整吧另外,作为技术,你是否合格。这里是技术讨论而已,并不是代替帮你开发。就算这次行了,下一次呢?知识在自己手才是最珍贵的。我们做技术的,别人给出关键代码,剩下的地方自己去完善就好了。。我想问你,你连定时代码都不会写吗?
tiankun66不好意思,我忘记是你了。我重新发帖吧。说明是求代码帖。