www.pudn.com > 自动计划(autoplan)源代码___强烈推荐 .rar > Unt_Main.pas, change:2004-04-08,size:28333b
unit Unt_Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SkinControls, Skin, SkinEngine, SkinImage, ExtCtrls, SkinSlider,
ComCtrls, SkinButtons, SkinCheckBox, SkinLed, SkinProgressBar, SkinLabel,
StdCtrls, ImgList, Menus, DB,Registry, OleCtrls, SHDocVw,Unt_fun, Buttons,
CoolTrayIcon, TextTrayIcon, ALScrollingText, XPBarMenu,WAV_Volume,
TFlatHintUnit,shellapi,inifiles;
const
WM_CLOSEPLAN = WM_USER + 444;
WM_CLOSECOMPUT = WM_USER + 666;
type
TAUTOUPDATE=procedure(aHandle:THandle);Stdcall;//智能升级程序
TPlan = procedure(aHandle:THandle);stdcall; //执行计划接口函数
TPlugInfo = function():Pchar;Stdcall; //插件信息
type
TPlanList = record //定义差价结构
Name:string; //插件名称
Author:string; //作者
Date :string; //开发日期
Dec: string; //描述
State:boolean; //状态true,false
path :string; //插件路径
end;
TTestPlugin = class
Caption:String;
Address:THandle;
Call:Pointer;
end;
type
TAuto_Plan = class(TForm)
SkinEngine1: TSkinEngine;
SkinForm1: TSkinForm;
SkinImage1: TSkinImage;
Timer1: TTimer;
SkinSlider1: TSkinSlider;
SkinButton1: TSkinButton;
SkinButton2: TSkinButton;
SkinButton3: TSkinButton;
SkinButton4: TSkinButton;
SkinButton5: TSkinButton;
SkinButton6: TSkinButton;
SkinButton7: TSkinButton;
SkinButton8: TSkinButton;
SkinButton9: TSkinButton;
SkinButton10: TSkinButton;
SkinButton11: TSkinButton;
SkinButton12: TSkinButton;
SkinButton13: TSkinButton;
SkinButton14: TSkinButton;
Plan1: TSkinImage;
Plan2: TSkinImage;
Plan3: TSkinImage;
Plan4: TSkinImage;
Plan5: TSkinImage;
SkinProgressBar1: TSkinProgressBar;
ListBoxPlan: TListBox;
Image1: TImage;
Img_Stop: TImage;
ImageList1: TImageList;
PopupMenu1: TPopupMenu;
OpenPlug: TOpenDialog;
TimeClose: TTimer;
Img_Begin: TImage;
SavePlug: TSaveDialog;
SkinImage2: TSkinImage;
SkinImage3: TSkinImage;
Lb_Plan: TLabel;
SkinButton15: TSkinButton;
SkinButton16: TSkinButton;
SkinImage5: TSkinImage;
SkinImage6: TSkinImage;
SkinRing: TSkinImage;
Lb_Nian: TLabel;
SkinButton17: TSkinButton;
SkinButton18: TSkinButton;
SkinButton19: TSkinButton;
SkinButton20: TSkinButton;
TimeRing: TTimer;
Timer2: TTimer;
CoolTrayIcon1: TCoolTrayIcon;
Timer3: TTimer;
Lb_Count: TLabel;
TimeCount: TTimer;
Lb_info: TALScrollingText;
N3: TMenuItem;
AutoPlan1: TMenuItem;
N4: TMenuItem;
SkinButton21: TSkinButton;
N1: TMenuItem;
FlatHint1: TFlatHint;
N2: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
z1: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
SkinStudiocom1: TMenuItem;
XPBarMenu1: TXPBarMenu;
Lb_Time: TSkinLabel;
Lb_TimeTotal: TSkinLabel;
SkinButton22: TSkinButton;
procedure Timer1Timer(Sender: TObject);
procedure SkinButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SkinButton5Click(Sender: TObject);
procedure ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
procedure ListBoxPlanMeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
procedure ListBoxPlanDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ListBoxPlanMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ListBoxPlanClick(Sender: TObject);
procedure ListBoxPlanDblClick(Sender: TObject);
procedure SkinButton1Click(Sender: TObject);
procedure TimeCloseTimer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure SkinButton2Click(Sender: TObject);
procedure SkinButton8Click(Sender: TObject);
procedure SkinButton7Click(Sender: TObject);
procedure SkinImage5DblClick(Sender: TObject);
procedure TimeRingTimer(Sender: TObject);
procedure SkinButton4Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure SkinButton14Click(Sender: TObject);
procedure CoolTrayIcon1Click(Sender: TObject);
procedure SkinButton17Click(Sender: TObject);
procedure SkinButton18Click(Sender: TObject);
procedure SkinButton19Click(Sender: TObject);
procedure TimeCountTimer(Sender: TObject);
procedure SkinButton20Click(Sender: TObject);
procedure SkinButton16Click(Sender: TObject);
procedure SkinButton15Click(Sender: TObject);
procedure Label2DblClick(Sender: TObject);
procedure SkinImage1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure SkinButton21Click(Sender: TObject);
procedure AutoPlan1Click(Sender: TObject);
procedure SkinSlider1Change(Sender: TObject);
procedure SkinButton6Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure z1Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure SkinStudiocom1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure SkinButton22Click(Sender: TObject);
private
t:integer;
vint_Cout:integer;
CloseType :integer;
ListPlan:array of TPlanList; //任务列表
PlanCount:integer;//任务数
ListRect:trect;{ Private declarations }
FunctionName :String;
PathStr :String;
procedure LoadPlugIns();
procedure LoadPlugIn(sr:TSearchRec;Aindex:integer);
procedure DoIt(LibName :string);
procedure AutoPlanUpdate();//智能升级
procedure AppMessage(var Msg: TMsg; var Handled: Boolean);
procedure ONMessage(var t:TMessage);message 8888;
public
strver :string ;//版本
HavNewVer:boolean; //是否有新版本
vstr_alarmTime:ttime;//设置报警时间{ Public declarations }
procedure OnNoNewVer(Sender: TObject); //检查新版本
end;
var
Auto_Plan: TAuto_Plan;
i:integer;
implementation
uses Unt_Rep, Unt_Confif, Unt_About, Unt_alarm;
{$R *.dfm}
procedure TAuto_Plan.Timer1Timer(Sender: TObject);
begin
case PlanCount of
1: begin
Plan1.Visible := not Plan1.Visible;
Plan2.Visible := false;
Plan3.Visible := false;
Plan4.Visible := false;
Plan5.Visible := false;
end;
2: begin
Plan1.Visible := not Plan1.Visible ;
plan2.Visible := Plan1.Visible ;
Plan3.Visible := false;
Plan4.Visible := false;
Plan5.Visible := false;
end;
3: begin
Plan1.Visible := not Plan1.Visible ;
Plan2.Visible := Plan1.Visible ;
Plan3.Visible := Plan1.Visible ;
Plan4.Visible := false;
Plan5.Visible := false;
end;
4: begin
Plan1.Visible := not Plan1.Visible ;
Plan2.Visible := Plan1.Visible ;
Plan3.Visible := Plan1.Visible ;
Plan4.Visible := Plan1.Visible ;
Plan5.Visible := false;
end;
5: begin
Plan1.Visible := not Plan1.Visible ;
Plan2.Visible := Plan1.Visible ;
Plan3.Visible := Plan1.Visible ;
Plan4.Visible := Plan1.Visible ;
Plan5.Visible := Plan1.Visible ;
end;
else
begin
Plan1.Visible := false ;
Plan2.Visible := false ;
Plan3.Visible := false ;
Plan4.Visible := false ;
Plan5.Visible := false ;
end;
end;
end;
procedure TAuto_Plan.SkinButton3Click(Sender: TObject);
begin
Close;
end;
procedure TAuto_Plan.FormCreate(Sender: TObject);
var
Reg: TRegistry;
l,r:WORD;
begin
try
SkinProgressBar1.Position := 0;
Application.OnMessage := AppMessage ;
GetWaveVolume(l,r);
SkinSlider1.MaxValue := 65535;
SkinSlider1.Position := l;
PlanCount := 0 ;{初始化计划任务为零}
Lb_Time.Font.Color := RGB(156,207,255);
FunctionName := 'Plan';{函数名}
//LoadPlugIns; {装载插件}
Lb_Nian.Caption := FormatDateTime( 'MM-DD...' ,NOW);
Lb_Info.Font.Color := RGB(156,207,255);
Lb_TimeTotal.Font.Color := RGB(156,207,255);
getnewver;
Lb_Info.Text := 'AutoPlan v'+ ver + ', Author:freedomhua, All CopyRight by Skin-Studio.com, Inc...';
GetLeaveTime;
ListBoxPlan.Color := RGB(206,203,206);
if InternetConnected then
SkinImage1.Visible := true
else
SkinImage1.Visible := false;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\AutoPlan', True) then
begin
//*********************************自动加载插件
Reg.OpenKey('plug',True);
if Reg.ReadBool('plug') then
LoadPlugIns; {装载插件}
//*********************************************
end;
finally
Reg.CloseKey;
Reg.Free ;
end;
except
end;
end;
procedure TAuto_Plan.SkinButton5Click(Sender: TObject);
begin
frm_rep := TFrm_Rep.Create(application);
frm_rep.show;
end;
procedure TAuto_Plan.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
begin
//ListView1.Canvas.Brush.Color := rgb(239,235,239);
//ListView1.Canvas.FillRect(arect);
end;
procedure TAuto_Plan.ListBoxPlanMeasureItem(Control: TWinControl;
Index: Integer; var Height: Integer);
begin
// Height :=20;
end;
procedure TAuto_Plan.ListBoxPlanDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap; { temporary variable for the item抯 bitmap }
Offset: Integer; { text offset width }
begin
ListRect := Rect;
ListBoxPlan.Color := RGB(206,203,206);
With (Control as TListBox).Canvas do { draw on control canvas, not on the form }
Begin
Brush.Color := RGB(206,203,206);
FillRect(Rect); { clear the rectangle }
Offset := 20; { provide default offset }
font.Color := clBlack;
Draw(Rect.Left+2 ,Rect.Top+2,Image1.Picture.Graphic);
if ListPlan[Index].State then {如果该任务运行,画运行状态图标}
Draw(rect.Right-2-Img_Begin.Width,Rect.Top +2,Img_Begin.Picture.Graphic)
else
Draw(rect.Right-2-Img_Stop.Width,Rect.Top +2,Img_Stop.Picture.Graphic);
TextOut(Rect.Left + Offset, Rect.Top+1, (Control as TListBox).Items[Index]) ;
IF odFocused in State then
begin
Brush.Color := rgb(148,178,206);
FillRect(Rect);
Font.Color := clBlack;
Draw(Rect.Left+2 ,Rect.Top+2,Image1.Picture.Graphic);
if ListPlan[Index].State then {如果该任务运行,画运行状态图标}
Draw(rect.Right-2-Img_Begin.Width,Rect.Top +2,Img_Begin.Picture.Graphic)
else
Draw(rect.Right-2-Img_Stop.Width,Rect.Top +2,Img_Stop.Picture.Graphic);
TextOut(Rect.Left + Offset, Rect.Top+1, (Control as TListBox).Items[Index]) ;
end;
if odDefault in state then
begin
Brush.Color := RGB(206,203,206);
FillRect(Rect); { clear the rectangle }
Offset := 20; { provide default offset }
Draw(Rect.Left+2 ,Rect.Top+2,Image1.Picture.Graphic);
if ListPlan[Index].State then {如果该任务运行,画运行状态图标}
Draw(rect.Right-2-Img_Begin.Width,Rect.Top +2,Img_Begin.Picture.Graphic)
else
Draw(rect.Right-2-Img_Stop.Width,Rect.Top +2,Img_Stop.Picture.Graphic);
TextOut(Rect.Left + Offset, Rect.Top+1, (Control as TListBox).Items[Index]) ;
end;
end;
end;
procedure TAuto_Plan.ListBoxPlanMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
h:HWND;
dc:HDC;
begin
{ h := GetDesktopWindow;
dc:=GetDC(h);
BitBlt(dc,2,2,20,20,Image1.Canvas.Handle,1,1,SRCCOPY);}
end;
procedure TAuto_Plan.ListBoxPlanClick(Sender: TObject);
begin
// label2.Caption := '说明:' + trim(ListPlan[ListBoxPlan.itemindex].Dec) ;
end;
procedure TAuto_Plan.LoadPlugIns;
var
sr: TSearchRec;
path: string;
Found: Integer;
cPLUGIN_MASK :string;
i:integer;
begin
i := 0;
cPLUGIN_MASK := '*.PLG';
path := ExtractFilePath(Application.Exename) ;
try
Found := FindFirst(path + cPLUGIN_MASK, 0, sr);
while Found = 0 do begin
Inc(i);
SetLength(ListPlan,i); {给插件数组负值,说明数组大小}
ListPlan[i-1].State := false;
LoadPlugin(sr,i-1);
Found := FindNext(sr);
end;
finally
FindClose(sr);
end;
end;
procedure TAuto_Plan.LoadPlugIn(sr: TSearchRec;Aindex:integer);
var
i:integer;
planinfo:TPlugInfo;
LibHandle: Integer;
plan: TPlan;//
FileName :string;
begin
FileName := ExtractFilePath(Application.Exename) + sr.Name;
LibHandle := LoadLibrary(PChar(FileName));
if LibHandle <> 0 then
begin
@PlanInfo:=GetProcAddress(LibHandle,pchar('PlugInfo')); //取插件信息
if Assigned(@PlanInfo) then
begin
ListPlan[Aindex].Name := Trim(copy(PlanInfo,1,40)) ;//插件名称
ListPlan[Aindex].Author := Trim(copy(PlanInfo,41,10)) ;//开发者
ListPlan[Aindex].Date := Trim(copy(PlanInfo,51,15)) ;//开发日期
ListPlan[Aindex].Dec := Trim(copy(PlanInfo,66,100)) ;//描述
ListPlan[Aindex].path := FileName ;//path
ListBoxPlan.Items.Add( Trim(copy(PlanInfo,1,40)));
end;
//FreeLibrary(LibHandle);
end
else
Application.MessageBox(pchar('加载 "' + sr.Name + '" 产生错误.'),'信息',MB_OK+MB_ICONINFORMATION);
end;
procedure TAuto_Plan.DoIt(LibName: string);
var
Plan :TPlan;
LibH :THandle;
begin
if LibName = '' then Exit;
LibH := LoadLibrary(PChar(LibName));
if LibH = 0 then Exit;
@Plan := GetProcAddress(LibH,pchar('Plan'));
if @Plan <> nil then
Plan(Application.handle);
FreeLibrary(LibH);
end;
procedure TAuto_Plan.ListBoxPlanDblClick(Sender: TObject);
begin
ListPlan[ListBoxPlan.ItemIndex].State := not ListPlan[ListBoxPlan.ItemIndex].State;
if ListBoxPlan.Items.Count <= 0 then Exit;
if ListBoxPlan.ItemIndex < 0 then Exit;
if (ListPlan[ListBoxPlan.ItemIndex].State) and
(PlanCount<6)
then
begin
SendMessage(handle,8888,1,0);
DoIt(ListPlan[ListBoxPlan.ItemIndex].path)
end
else
begin
TimeClose.Enabled := false;
SendMessage(handle,8888,0,0);
ListBoxPlan.Invalidate;
end;
end;
procedure TAuto_Plan.SkinButton1Click(Sender: TObject);
var
sr: TSearchRec;
path: string;
Found: Integer;
cPLUGIN_MASK :string;
i:integer;
LibHandle: Integer;
PLAN :TPlan;
planinfo:TPlugInfo;
begin
i := 0;
cPLUGIN_MASK := '*.dll';
OpenPlug.Filter := '插件(*.PLG)|*.Plg|所有文件|*.*' ;
OpenPlug.Title := '添加插件';
OpenPlug.Execute;
if OpenPlug.FileName = '' then exit;
path := OpenPlug.FileName ;
SetLength(ListPlan,ListBoxPlan.Items.Count+1); {给插件数组负值,说明数组大小}
ListPlan[ListBoxPlan.Items.Count].State := false;
try
LibHandle := LoadLibrary(PChar(path));
if LibHandle <> 0 then
begin
@plan := GetProcAddress(LibHandle,PChar(FunctionName));
if Assigned(@plan) then
else
begin
MessageDlg('File "' + sr.Name + '" is not a valid plug-in.',
mtInformation, [mbOK], 0);
end;
@PlanInfo:=GetProcAddress(LibHandle,pchar('PlugInfo')); //取插件信息
if Assigned(@PlanInfo) then
begin
ListPlan[ListBoxPlan.Items.Count].Name := Trim(copy(PlanInfo,1,40)) ;//插件名称
ListPlan[ListBoxPlan.Items.Count].Author := Trim(copy(PlanInfo,41,10)) ;//开发者
ListPlan[ListBoxPlan.Items.Count].Date := Trim(copy(PlanInfo,51,15)) ;//开发日期
ListPlan[ListBoxPlan.Items.Count].Dec := Trim(copy(PlanInfo,66,100)) ;//描述
ListPlan[ListBoxPlan.Items.Count].path := path ;//path
ListBoxPlan.Items.Add( Trim(copy(PlanInfo,1,40)));
end;
//FreeLibrary(LibHandle);
end
else
MessageDlg('An error occurred loading the plug-in "' +
sr.Name + '".', mtError, [mbOK], 0);
finally
end;
end;
procedure TAuto_Plan.ONMessage(var t: TMessage);
begin
if t.WParam=1 then
begin
if PlanCount > 5 then exit;
inc(PlanCount);
end
else
begin
if PlanCount <0 then exit;
Dec(PlanCount);
end;
if PlanCount <=0 then PlanCount := 0;
end;
procedure TAuto_Plan.TimeCloseTimer(Sender: TObject);
begin
Lb_Time.Caption := '00:' + Format('%.2d',[I])+'/';
SkinProgressBar1.MaxValue := strtoint(copy(Auto_Plan.Lb_TimeTotal.Caption,4,2));
SkinProgressBar1.Step := strtoint(copy(Auto_Plan.Lb_TimeTotal.Caption,4,2));
SkinProgressBar1.Position := i;
if i >= strtoint(copy(Auto_Plan.Lb_TimeTotal.Caption,4,2)) then
begin
TimeClose.Enabled:=false; { TODO 2 : 添加关机过程 }
{关机方式}
if CloseType = 0 then //关机
ExitWindows(EWX_SHUTDOWN + EWX_FORCE + EWX_POWEROFF )
else if CloseType = 1 then //重启
ExitWindows(EWX_REBOOT + EWX_FORCE)
else if CloseType = 2 then //注销
ExitWindows(EWX_LOGOFF + EWX_FORCE);
end;
inc(i);
end;
procedure TAuto_Plan.Button2Click(Sender: TObject);
begin
SendMessage(handle,8888,0,0);
end;
procedure TAuto_Plan.SkinButton2Click(Sender: TObject);
var
PLAN :TPlan;
LibH :THandle;
var i:integer;
begin
if ListBoxPlan.ItemIndex < 0 then exit;
begin
if ListPlan[ListBoxPlan.ItemIndex].State then Dec(PlanCount);
for i := ListBoxPlan.ItemIndex + 1 to ListBoxPlan.Items.Count-1 do
begin
ListPlan[i-1].Name := ListPlan[i].Name ;//插件名称
ListPlan[i-1].Author := ListPlan[i].Author ;//开发者
ListPlan[i-1].Date := ListPlan[i].Date ;//开发日期
ListPlan[i-1].Dec := ListPlan[i].Dec ;//描述
ListPlan[i-1].path := ListPlan[i].path ;//path
ListPlan[i-1].State := ListPlan[i].State;
end;
ListBoxPlan.Items.Delete(ListBoxPlan.ItemIndex);
SetLength(listplan,ListBoxPlan.Items.Count);
end;
end;
procedure TAuto_Plan.SkinButton8Click(Sender: TObject);
var
i:integer;
f: TextFile;
begin
SavePlug.Execute;
if SavePlug.FileName = ' ' then exit;
if FileExists(SavePlug.FileName) then
DeleteFile(SavePlug.FileName);
AssignFile(f, SavePlug.FileName);
for i:= 0 to ListBoxPlan.Count - 1 do
begin
try
if FileExists(SavePlug.FileName) then
Append( F )
else
ReWrite( F );
Writeln(f,format('%40s%10s%15s%100s%1s%100s',[ListPlan[i].Name,ListPlan[i].Author,
ListPlan[i].Date,ListPlan[i].Dec,'0',ListPlan[i].Path]));
finally
CloseFile( F );
end;
end;
end;
procedure TAuto_Plan.SkinButton7Click(Sender: TObject);
var
sr: TSearchRec;
path: string;
Found: Integer;
cPLUGIN_MASK :string;
i:integer;
LibHandle: Integer;
PLAN :TPlan;
planinfo:TPlugInfo;
F: Textfile;
Ls:string;
begin
i := 0;
cPLUGIN_MASK := '*.plg';
OpenPlug.Filter := '计划列表(*.Pst)|*.Pst' ;
OpenPlug.Title := '打开计划列表';
OpenPlug.Execute;
if OpenPlug.FileName = '' then exit;
ListBoxPlan.Clear;
SetLength(listplan,0);
AssignFile(F, OpenPlug.FileName);
FileMode := 0;
Reset(F);
while not Eof(F) do
begin
SetLength(ListPlan,I+1); {给插件数组负值,说明数组大小}
Readln(F,Ls);
ListPlan[i].path := Trim(Copy(Ls,167,100));
try
LibHandle := LoadLibrary(PChar(ListPlan[i].path));
if LibHandle <> 0 then
begin
@plan := GetProcAddress(LibHandle,PChar(FunctionName));
if Assigned(@plan) then
else
begin
Application.MessageBox(pchar('文件 "' + sr.Name + '" 不是合法的插件.'),'信息',MB_OK+MB_ICONINFORMATION);
end;
@PlanInfo:=GetProcAddress(LibHandle,pchar('PlugInfo')); //取插件信息
if Assigned(@PlanInfo) then
begin
ListPlan[i].Name := Trim(Copy(Ls,1,40));
ListPlan[i].Author := Trim(Copy(Ls,41,10));
ListPlan[i].Date := Trim(Copy(Ls,51,15));
ListPlan[i].Dec := Trim(Copy(Ls,66,100));
ListPlan[i].State := False;
ListPlan[i].path := Trim(Copy(Ls,167,100));
ListBoxPlan.Items.Add( Trim(copy(PlanInfo,1,40)));
end;
//FreeLibrary(LibHandle);
end
else
MessageDlg('An error occurred loading the plug-in "' +
sr.Name + '".', mtError, [mbOK], 0);
Inc(I);
finally
end;
end;
CloseFile(F);
end;
procedure TAuto_Plan.SkinImage5DblClick(Sender: TObject);
begin
SkinImage5.Visible := NOT SkinImage5.Visible;
end;
procedure TAuto_Plan.TimeRingTimer(Sender: TObject);
begin
SkinRing.Visible := not SkinRing.Visible;
if time>=vstr_alarmTime then
begin
TimeRing.Enabled := false;
SkinRing.Visible := false;
SkinRing.Hint :='';
Application.MessageBox('您设置的提醒时间到了!','提醒',mb_ok+MB_ICONWARNING);
end;
end;
procedure TAuto_Plan.SkinButton4Click(Sender: TObject);
begin
frm_config := tfrm_config.create(self);
Frm_Config.ShowModal;
end;
procedure TAuto_Plan.Timer2Timer(Sender: TObject);
begin
Lb_Plan.Caption := TimeToStr(TIME);
end;
procedure TAuto_Plan.SkinButton14Click(Sender: TObject);
begin
ShowWindow(handle,SW_HIDE);
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle,GWL_EXSTYLE,
GetWindowLong(Application.Handle,GWL_EXSTYLE
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW) ) ;
end;
procedure TAuto_Plan.CoolTrayIcon1Click(Sender: TObject);
begin
Auto_Plan.Show ;
ShowWindow(Auto_Plan.Handle,SW_SHOWNORMAL);
end;
procedure TAuto_Plan.SkinButton17Click(Sender: TObject);
begin
Frm_Alarm := TFrm_Alarm.Create(self);
Frm_Alarm.ShowModal;
end;
procedure TAuto_Plan.SkinButton18Click(Sender: TObject);
begin
TimeRing.Enabled := false;
end;
procedure TAuto_Plan.SkinButton19Click(Sender: TObject);
begin
Lb_Plan.visible := false;
Lb_Count.Visible := true;
TimeCount.Enabled := true;
end;
procedure TAuto_Plan.TimeCountTimer(Sender: TObject);
begin
SkinImage5.Visible := not SkinImage5.Visible;
inc(t);
if t>60 then
Lb_Count.Caption := '00:'+format('%.2d:', [(t div 2 div 60)]) + format('%.2d', [ t div 2 mod 60])
else
Lb_Count.Caption := '00:00:' + format('%.2d', [t div 2]);
end;
procedure TAuto_Plan.SkinButton20Click(Sender: TObject);
begin
if TimeCount.Enabled then
begin
TimeCount.Enabled :=false ;
skinimage5.Visible:= true;
end
else
begin
skinimage5.Visible := false;
TimeCount.Enabled := false;
t:=0;
Lb_Count.Caption := '00:00:00';
end;
end;
procedure TAuto_Plan.SkinButton16Click(Sender: TObject);
begin
Lb_plan.Visible := false;
Lb_Count.Visible := true;
end;
procedure TAuto_Plan.SkinButton15Click(Sender: TObject);
begin
Lb_plan.Visible := true;
Lb_Count.Visible := false ;
end;
procedure TAuto_Plan.Label2DblClick(Sender: TObject);
begin
{label1.Caption := '作者:' + ListPlan[ListBoxPlan.itemindex].Author + ' ' +
ListPlan[ListBoxPlan.itemindex].Date ;}
Application.MessageBox(pchar('作者:'+listplan[ListBoxPlan.itemindex].author),'提示');
end;
procedure TAuto_Plan.AutoPlanUpdate;
begin
if WinExec('autoplanupdate.exe',1) <= 31 then
Application.MessageBox('找不到 AutoPlanUpdate 智能升级程序程序!','信息',MB_OK+MB_ICONWARNING);
end;
procedure TAuto_Plan.SkinImage1Click(Sender: TObject);
begin
AutoPlanUpdate
end;
procedure TAuto_Plan.N3Click(Sender: TObject);
begin
AutoPlanUpdate;
end;
procedure TAuto_Plan.OnNoNewVer(Sender: TObject);
begin
HavNewVer := false;
Timer3.Enabled := false;
SkinImage2.Visible := false;
end;
procedure TAuto_Plan.Timer3Timer(Sender: TObject);
begin
SkinImage2.Visible := not SkinImage2.Visible ;
end;
procedure TAuto_Plan.FormPaint(Sender: TObject);
begin
ListBoxPlan.Color := RGB(206,203,206);
end;
procedure TAuto_Plan.SkinButton21Click(Sender: TObject);
var
t : TPoint;
begin
GetCursorPos(t);
PopupMenu1.Popup(t.X,t.Y);
end;
procedure TAuto_Plan.AutoPlan1Click(Sender: TObject);
begin
frm_about := TFrm_About.Create(self);
Frm_About.ShowModal;
end;
procedure TAuto_Plan.SkinSlider1Change(Sender: TObject);
begin
SetWaveVolume(SkinSlider1.Position,SkinSlider1.Position);
end;
procedure TAuto_Plan.SkinButton6Click(Sender: TObject);
begin
ShowHint := not ShowHint;
end;
procedure TAuto_Plan.N13Click(Sender: TObject);
begin
if WindowState = wsNormal then
begin
ShowWindow(handle,SW_HIDE);
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle,GWL_EXSTYLE,
GetWindowLong(Application.Handle,GWL_EXSTYLE
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW) ) ;
end
else
begin
Auto_Plan.Show ;
ShowWindow(Auto_Plan.Handle,SW_SHOWNORMAL);
end;
end;
procedure TAuto_Plan.N6Click(Sender: TObject);
begin
ShowHint := not ShowHint;
end;
procedure TAuto_Plan.N5Click(Sender: TObject);
begin
frm_config := tfrm_config.create(self);
Frm_Config.ShowModal;
end;
procedure TAuto_Plan.N4Click(Sender: TObject);
begin
WinHelp(handle,'AutoPlan.Hlp',HELP_CONTENTS,0);
end;
procedure TAuto_Plan.N7Click(Sender: TObject);
begin
close;
end;
procedure TAuto_Plan.z1Click(Sender: TObject);
var
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('ver.dll');
with MyIniFile do
begin
ShellExecute(Handle,'open',
PChar(MyIniFile.ReadString('url','url','http://www.skin-studio.com')),
nil,nil, SW_SHOWNORMAL);
end;
MyIniFile.Free;
end;
procedure TAuto_Plan.N12Click(Sender: TObject);
var
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('ver.dll');
with MyIniFile do
begin
ShellExecute(Handle,'open',
PChar('mailto:freedomhua@163.com'),
nil,nil, SW_SHOWNORMAL);
end;
MyIniFile.Free;
end;
procedure TAuto_Plan.SkinStudiocom1Click(Sender: TObject);
var
MyIniFile: TIniFile;
begin
MyIniFile := TIniFile.Create('ver.dll');
with MyIniFile do
begin
ShellExecute(Handle,'open',
PChar('http://www.skin-studio.com'),
nil,nil, SW_SHOWNORMAL);
end;
MyIniFile.Free;
end;
procedure TAuto_Plan.N2Click(Sender: TObject);
begin
frm_rep := TFrm_Rep.Create(application);
frm_rep.show;
end;
procedure TAuto_Plan.SkinButton22Click(Sender: TObject);
begin
WinHelp(handle,'AutoPlan.HLP',HELP_CONTENTS,0);
end;
procedure TAuto_Plan.AppMessage(var Msg: TMsg; var Handled: Boolean);
var
reg :TRegistry;
begin
if Msg.message = WM_CLOSEPLAN then //如果接收到停止任务消息
begin
TimeClose.Enabled := false;
SendMessage(handle,8888,0,0);
ListPlan[ListBoxPlan.ItemIndex].State := false;
ListBoxPlan.Invalidate;
end;
if Msg.message <> WM_CLOSECOMPUT then exit;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\AutoPlan', True) then
begin
//*********************************关机类型
Reg.OpenKey('CloseType',True);
if Msg.WParam = 0 then
Msg.LParam := Reg.ReadInteger('Type');
//*********************************************
end;
finally
Reg.CloseKey;
Reg.Free ;
end;
{关机方式}
if Msg.LParam = 0 then //关机
CloseType := 0
else if Msg.LParam = 1 then //重启
CloseType := 1
else if Msg.LParam = 2 then //注销
CloseType := 2;
TimeClose.Enabled := true;
{是否播放背景音乐}
END;
end.