unit AutoShut1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus,SetTime, AppEvnts,shellapi;
type
TForm1 = class(TForm)
Timer1: TTimer;
MainMenu1: TMainMenu;
Setting1: TMenuItem;
imeSet1: TMenuItem;
Exit1: TMenuItem;
ApplicationEvents1: TApplicationEvents;
PopupMenu1: TPopupMenu;
imeSet2: TMenuItem;
Exit2: TMenuItem;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
procedure imeSet1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
// procedure MinimizeToTray(Var Msg:TWMSysCommand);Message WM_SYSCOMMAND;
procedure TrayNot(Var Msg:TMessage); message WM_USER;
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure imeSet2Click(Sender: TObject);
procedure Exit2Click(Sender: TObject);
private
{ Private declarations }
a:NOTIFYICONDATA;
procedure MinimizeIt();
public
{ Public declarations }
end;
var
Form1: TForm1;
P,Ti1:Pchar;
Flags:Longint;
implementation
{$R *.dfm}
{procedure Tform1.MinimizeToTray(Var Msg:TWMSysCommand);
Begin
if (Msg.CmdType=SC_MINIMIZE) then
Begin
MinimizeIt();
End;
inherited;
End;}
procedure Tform1.MinimizeIt;
Begin
a.cbSize:=sizeof(a);
a.Wnd:=Self.Handle;
a.uFlags:=NIF_ICON+NIF_MESSAGE+NIF_TIP;
a.uCallbackMessage:=WM_USER;
a.hIcon:=application.Icon.Handle;
a.szTip:='AutoShutDown';
Shell_NotifyIcon(NIM_ADD,@a);
End;
procedure Tform1.TrayNot(var Msg:TMessage);
var
X,Y:Tpoint;
J,K:Integer;
Begin
GetCursorPos(X);
GetCursorPos(Y);
J:=X.X;
K:=Y.Y;
if Msg.LParam=WM_RBUTTONDOWN then
Begin
PopupMenu1.Popup(J,K);
End;
if Msg.LParam=WM_LBUTTONDOWN then
Begin
ShowWindow(Application.Handle,SW_SHOW);
Application.Restore;
Shell_NotifyIcon(NIM_DELETE,@a);
End;
End;
procedure Shutdown(Force:Boolean);
Begin
if Force Then
Begin
Flags:=EWX_SHUTDOWN+EWX_FORCE;
ExitWindowsEx(Flags,0);
End;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
GetMem(Ti1,25);
Ti1^:=Chr(0);
StrLCat(Ti1,PChar(TimeToStr(Now)),5);
P:=AnsiLastChar(Ti1);
if P= ':' then
Begin
Ti1^:=Chr(0);
StrLCat(Ti1,PChar(TimeToStr(Now)),4);
End;
Edit1.Text:=Ti1;
if Ti1= Form2.Edit1.Text then
Begin
Timer1.Enabled:=False;
Shutdown(True);
End;
end;
procedure TForm1.imeSet1Click(Sender: TObject);
begin
Form2.Visible:=True;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
Application.Terminate;
end;
procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
MinimizeIt;
ShowWindow(Application.Handle,SW_HIDE);
end;
procedure TForm1.ApplicationEvents1Restore(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
ShowWindow(Application.Handle,SW_NORMAL);
end;
procedure TForm1.imeSet2Click(Sender: TObject);
begin
Form2.Visible:=True;
end;
procedure TForm1.Exit2Click(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@a);
Application.Terminate;
end;
end.
Ali nece da radi prog. Ne prijavljuje nikakvu gresku, jednostavno nece da ugasi komp.
Imate li vi neke kodove?
Objavite ih
maybe baby
baby meybe
baby meybe

Izvorni kod za Shut down