{ $Id: gplprog.pt,v 1.2 2002/09/07 15:40:47 peter Exp 2010/04/30 20:21:54 peter Exp $
This file is part of ShutDown
Copyright (c) 2010 by Phi
Main File
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
//COMPILATO CON FREE PASCAL
program Shutdown;
{$R Resourcesht2.RES}
{$apptype gui}
uses winsys, Windows, graph;
const
G1 : smallint = VGA;
G2 : smallint = 1;
procedure delay(ms:longint);
begin
sleep(ms);
end;
Var
Icona, freccia : Hicon;
letto : boolean;
I : longword;
sc : byte;
pos:point;
procedure wrimm(x,y : word;contorno:boolean);
begin
if contorno then bar3d(x,y,x+37,y+37,0,true);
drawicon(windc,x+3,y+3,icona);
drawicon(bitmapdc,x+3,y+3,icona);
end;
function mouse(finestra:hwnd;msg:uint;wp:wparam;lp:lparam):longint;stdcall;
function intasto(x,y:word):boolean;
begin
intasto:=(pos.x>=x)and(pos.y>=y)and(pos.x<(x+38))and(pos.y<(y+38));
end;
begin
if (msg=wm_lbuttondblclk)or(msg=wm_lbuttondown)then begin
getcursorpos(@pos);
screentoclient(Graphwindow,@pos);
if intasto(602,0) then halt;
if intasto(145,150) then begin
sc := 1;
letto := true;
end;
if intasto(305,150) then begin
sc := 2;
letto := true;
end;
if intasto(465,150) then begin
sc := 3;
letto := true;
end;
end;
mouse:=0;
end;
function tastiera(finestra:hwnd;msg:uint;wp:wparam;lp:lparam):longint;stdcall;
begin
if (msg = wm_char) and (char(wp)=#13) then letto := true;
if (msg = wm_keydown) then case (wp) of
vk_left: if sc = 1 then sc := 3 else sc:=sc-1;
vk_right: if sc = 3 then sc := 1 else sc:=sc+1;
vk_end:sc:=3;
vk_home:sc:=1;
end;
tastiera:=0;
end;
procedure disegno;
begin
setcolor(0);
for I := 0 to 639 do begin
if i < 320 then setrgbpalette(0,32-(I div 10),32-(I div 10),150)
else setrgbpalette(0,((I-320) div 10),((I-320) div 10),150);
line(I,0,I,60);
line(I,300,I,350);
if i < 320 then setrgbpalette(0,(I div 3),(I div 3),250)
else setrgbpalette(0,106-((I-320) div 3),106-((I-320) div 3),250);
line(I,64,I,300);
end;
setcolor(14);setrgbpalette(14,255,255,0);
line(0,61,639,61);line(0,62,639,62);line(0,63,639,63);
line(0,301,639,301);line(0,302,639,302);
icona := icon; wrimm(5,10,false);
icona:=extracticon(hinstance,'phi immgrd.dll',0);
wrimm(5,310,false);
settextstyle(0,0,2);outtextxy(100,18,'Spegni il computer');settextstyle(0,0,0);
setcolor(15);
outtextxy(140,130,'SPEGNI');
outtextxy(285,130,'DISCONETTI');
outtextxy(455,130,'RIAVVIA');
setcolor(0);setrgbpalette(0,0,0,0);
icona:=loadicon(hinstance,pchar(1)); wrimm(145,150,true);
icona:=loadicon(hinstance,pchar(3)); wrimm(305,150,true);
icona:=loadicon(hinstance,pchar(2)); wrimm(465,150,true);
icona:=loadicon(hinstance,pchar(4)); wrimm(602,0,false);
outtextxy(160,332,'Software developed by Andrea Agnolin');
outtextxy(60,341,'You can redistribute it under the terms of the GNU GPL, see copying.txt');
end;
BEGIN
startx := (getsystemmetrics(sm_cxscreen)-640) div 2;
starty := (getsystemmetrics(sm_cyscreen)-480) div 2;
ws_graph := ws_popupwindow;
icon := loadicon(hinstance,pchar(0));
freccia := loadicon(hinstance,pchar(5));
windowtitle := 'Shutdown v2';
graph.mousemessagehandler:=@mouse;
graph.charmessagehandler:=@tastiera;
initgraph(G1,G2,'');
disegno;
sc := 1;
repeat
for I := 69 to 561 do begin
if i < 320 then setrgbpalette(0,(I div 3),(I div 3),250)
else setrgbpalette(0,106-((I-320) div 3),106-((I-320) div 3),250);
line(I,200,I,240);
end;
delay(1);
drawicon(windc,120+(sc-1)*160,200,freccia);
drawicon(bitmapdc,120+(sc-1)*160,200,freccia);
delay(100);
until letto or not(iswindow(graphwindow));
if not(iswindow(graphwindow)) then halt(0);
case sc of
1:Spegni(EWX_POWEROFF);
3:Spegni(EWX_REBOOT);
2:Spegni(EWX_LOGOFF);
else MessageBox(0, 'Choose SHUTDOWN, RESTART or LOGOFF.', 'Shutdown', MB_OK + MB_ICONEXCLAMATION);
end;
END.