Salve a tutti sono di nuovo qui ..., e non sapevo che cazzo fare

« Older   Newer »
  Share  
Dragon[ITA]
CAT_IMG Posted on 4/5/2010, 20:30     +1   -1




Ecco qui un inutility sbura... LOL
(c'è il bug che se metti la finestra fuori dallo schermo si cancellano i numeri ma per il resto è sburo)
(per ripristinare i numeri basta ridurre e ripristinare la finestra)

ecco a voi l'OROLOGIO! (completamente in GDI+)

SPOILER (click to view)
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.0.0
Author: Dragon[ITA]

Script Function:
Segna l'ora >_>.

#ce ----------------------------------------------------------------------------

#include <gdiplus.au3>
#include <misc.au3>
#include <guiconstantsex.au3>
#include <staticconstants.au3>
#include <windowsconstants.au3>
$gui = GUICreate("TimeShift",250,250)
GUISetBkColor(0x000000,$gui)
GUISetState()

$Form1 = GUICreate("Colori", 162, 66, 291, 260)
$Graphic1 = GUICtrlCreateGraphic(8, 8, 41, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT,$SS_BLACKFRAME,$SS_NOTIFY))
GUICtrlSetBkColor(-1, 0xFF2222)
$Graphic2 = GUICtrlCreateGraphic(64, 8, 41, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT,$SS_BLACKFRAME,$SS_NOTIFY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Graphic3 = GUICtrlCreateGraphic(112, 8, 41, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT,$SS_BLACKFRAME,$SS_NOTIFY))
GUICtrlSetBkColor(-1, 0xFFFF00)
$Graphic4 = GUICtrlCreateGraphic(8, 40, 41, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT,$SS_BLACKFRAME,$SS_NOTIFY))
GUICtrlSetBkColor(-1, 0x00FF00)
$Graphic5 = GUICtrlCreateGraphic(64, 40, 41, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT,$SS_BLACKFRAME,$SS_NOTIFY))
GUICtrlSetBkColor(-1, 0xFF0000)

Global Const $PI = 3.1415926535897932384626433832795, $RAD = $PI/180

_GDIPlus_Startup()

$effg = _GDIPlus_GraphicsCreateFromHWND($gui)
$efft = TimerInit()
$effe = 0
_AntiAlias($effg,2)

$Family = _GDIPlus_FontFamilyCreate("Trebuchet MS")
$fontbrush1 = _GDIPlus_BrushCreateSolid(0xFF10FF10)
$fontbrush = _GDIPlus_BrushCreateSolid(0xFF000000)
$Format = _GDIPlus_StringFormatCreate ()
$Font = _GDIPlus_FontCreate ($Family, 10, 1)
$Layout1 = _GDIPlus_RectFCreate (171, 25, 140, 25)
$Layout2 = _GDIPlus_RectFCreate (210, 63, 140, 25)
$Layout3 = _GDIPlus_RectFCreate (226, 117, 250, 140)
$Layout4 = _GDIPlus_RectFCreate (210, 170, 140, 25)
$Layout5 = _GDIPlus_RectFCreate (170, 210, 140, 25)
$Layout6 = _GDIPlus_RectFCreate (116, 226, 115, 250)
$Layout7 = _GDIPlus_RectFCreate (59, 210, 140, 25)
$Layout8 = _GDIPlus_RectFCreate (22, 168, 140, 25)
$Layout9 = _GDIPlus_RectFCreate (9, 115, 25, 140)
$Layout10 = _GDIPlus_RectFCreate (22, 63, 25, 140)
$Layout11 = _GDIPlus_RectFCreate (59, 25, 25, 140)
$Layout12 = _GDIPlus_RectFCreate (115, 9, 140, 25)
_GDIPlus_GraphicsDrawStringEx ($effg, "01", $Font, $Layout1, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "02", $Font, $Layout2, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "03", $Font, $Layout3, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "04", $Font, $Layout4, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "05", $Font, $Layout5, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "06", $Font, $Layout6, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "07", $Font, $Layout7, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "08", $Font, $Layout8, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "09", $Font, $Layout9, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "10", $Font, $Layout10, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "11", $Font, $Layout11, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "12", $Font, $Layout12, $Format, $fontbrush1)

$blackrect = _GDIPlus_BrushCreateSolid(0x12000000)
$secpen1 = _GDIPlus_PenCreate(0xFFFF2222,1)
$secpen2 = _GDIPlus_PenCreate(0x12FF2222,1)
Dim $spoint[2] = [205,125]
$hourt = @HOUR
Dim $hpoint1[2] = [125,125+3],$hpoint2[2]=[125,125-3],$hpoint3[2]=[180,125]
$hourb1 = _GDIPlus_BrushCreateSolid(0xFFFFFF00)
$hourb2 = _GDIPlus_BrushCreateSolid(0x25FFFF00)
$mint = @MIN
$minb1 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$minb2 = _GDIPlus_BrushCreateSolid(0x20FFFFFF)
Dim $mpoint1[2] = [125,125+3],$mpoint2[2]=[125,125-3],$mpoint3[2]=[195,125]
$sect = @SEC
$pen = _GDIPlus_PenCreate(0xFF00FF00,1)
$pen2 = _GDIPlus_PenCreate(0xFFFF0000,1)
Dim $Center[2] = [125,125]
Dim $tac1[2] = [30, 125], $tac2[2] = [36, 125], $tacangle = 0
$ts = _PointRotate(@SEC*(360/60)-90,$center,$spoint)
_GDIPlus_GraphicsDrawLine($effg,125,125,$ts[0],$ts[1],$secpen1)
_GDIPlus_GraphicsDrawEllipse($effg,115,115,20,20,$pen)
$tm1 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint1)
$tm2 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint2)
$tm3 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint3)
Dim $minpoint[4][2] = [[3,0],[$tm1[0],$tm1[1]],[$tm2[0],$tm2[1]],[$tm3[0],$tm3[1]]]
_GDIPlus_GraphicsFillPolygon($effg,$minpoint,$minb1)
$hm1 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint1)
$hm2 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint2)
$hm3 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint3)
Dim $hourpoint[4][2] = [[3,0],[$hm1[0],$hm1[1]],[$hm2[0],$hm2[1]],[$hm3[0],$hm3[1]]]
_GDIPlus_GraphicsFillPolygon($effg,$hourpoint,$hourb1)
$inc = 1
Dim $color[6] = [0,0xFF2222,0xFFFFFF,0xFFFF00,0x00FF00,0xFF0000]
While 1
Switch GUIGetMsg()
Case -3
If WinActive("Colori") Then
GUISetState(@SW_HIDE,$Form1)
Else
Exit
EndIf
Case -10
GUISetState(@SW_SHOW,$Form1)
Case $GUI_EVENT_RESTORE
_GDIPlus_GraphicsDrawStringEx ($effg, "01", $Font, $Layout1, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "02", $Font, $Layout2, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "03", $Font, $Layout3, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "04", $Font, $Layout4, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "05", $Font, $Layout5, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "06", $Font, $Layout6, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "07", $Font, $Layout7, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "08", $Font, $Layout8, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "09", $Font, $Layout9, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "10", $Font, $Layout10, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "11", $Font, $Layout11, $Format, $fontbrush1)
_GDIPlus_GraphicsDrawStringEx ($effg, "12", $Font, $Layout12, $Format, $fontbrush1)
Case $Graphic1
$color[1] = _ChooseColor(2,$color[1],2)
If $color[1] <> 0x000000 And $color[1] <> -1 Then
_GDIPlus_PenDispose($secpen1)
_GDIPlus_PenDispose($secpen2)
$secpen1 = _GDIPlus_PenCreate("0xFF"&StringTrimLeft($color[1],2),1)
$secpen2 = _GDIPlus_PenCreate("0x12"&StringTrimLeft($color[1],2),1)
GUICtrlSetBkColor($Graphic1,$color[1])
EndIf
Case $Graphic2
$color[2] = _ChooseColor(2,$color[2],2)
If $color[2] <> 0x000000 And $color[2] <> -1 Then
$minb1 = _GDIPlus_BrushCreateSolid("0xFF"&StringTrimLeft($color[2],2))
$minb2 = _GDIPlus_BrushCreateSolid("0x20"&StringTrimLeft($color[2],2))
GUICtrlSetBkColor($Graphic2,$color[2])
EndIf
Case $Graphic3
$color[3] = _ChooseColor(2,$color[3],2)
If $color[3] <> 0x000000 And $color[3] <> -1 Then
$hourb1 = _GDIPlus_BrushCreateSolid("0xFF"&StringTrimLeft($color[3],2))
$hourb2 = _GDIPlus_BrushCreateSolid("0x25"&StringTrimLeft($color[3],2))
GUICtrlSetBkColor($Graphic3,$color[3])
EndIf
Case $Graphic4
$color[4] = _ChooseColor(2,$color[4],2)
If $color[4] <> 0x000000 And $color[4] <> -1 Then
_GDIPlus_PenDispose($pen)
$pen = _GDIPlus_PenCreate("0xFF"&StringTrimLeft($color[4],2),1)
GUICtrlSetBkColor($Graphic4,$color[4])
EndIf
Case $Graphic5
$color[5] = _ChooseColor(2,$color[5],2)
If $color[5] <> 0x000000 And $color[5] <> -1 Then
_GDIPlus_PenDispose($pen2)
$pen2 = _GDIPlus_PenCreate("0xFF"&StringTrimLeft($color[5],2),1)
GUICtrlSetBkColor($Graphic5,$color[5])
EndIf
EndSwitch
If TimerDiff($efft) > 20 Then
$effe += 1
$efft = TimerInit()
_GDIPlus_GraphicsFillEllipse($effg,29,29,192,192,$blackrect)
$tacangle+=360/60
$tp1 = _PointRotate($tacangle,$center,$tac1)
$tp2 = _PointRotate($tacangle,$center,$tac2)
_GDIPlus_GraphicsDrawLine($effg,$tp1[0],$tp1[1],$tp2[0],$tp2[1],$pen)
_GDIPlus_GraphicsFillEllipse($effg,122,122,6,6,$minb1)
$tp1 = _PointRotate($tacangle+180,$center,$tac1)
$tp2 = _PointRotate($tacangle+180,$center,$tac2)
_GDIPlus_GraphicsDrawLine($effg,$tp1[0],$tp1[1],$tp2[0],$tp2[1],$pen2)
_GDIPlus_GraphicsDrawEllipse($effg,125-$effe/2,125-$effe/2,$effe,$effe,$pen)
If $effe = 30 Or $effe = 0 Then
$effe = 0
EndIf
_GDIPlus_GraphicsDrawLine($effg,125,125,$ts[0],$ts[1],$secpen2)
if $sect <> @SEC Then
$sect = @SEC
$ts = _PointRotate($sect*(360/60)-90,$center,$spoint)
_GDIPlus_GraphicsDrawLine($effg,125,125,$ts[0],$ts[1],$secpen1)
EndIf
_GDIPlus_GraphicsFillPolygon($effg,$minpoint,$minb2)
_GDIPlus_GraphicsFillPolygon($effg,$hourpoint,$hourb2)
if $mint <> @MIN Then
$mint = @MIN
$tm1 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint1)
$tm2 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint2)
$tm3 = _PointRotate(@MIN*(360/60)-90,$center,$mpoint3)
$minpoint[1][0] = $tm1[0]
$minpoint[1][1] = $tm1[1]
$minpoint[2][0] = $tm2[0]
$minpoint[2][1] = $tm2[1]
$minpoint[3][0] = $tm3[0]
$minpoint[3][1] = $tm3[1]
_GDIPlus_GraphicsFillPolygon($effg,$minpoint,$minb1)
$hm1 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint1)
$hm2 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint2)
$hm3 = _PointRotate((@HOUR+@MIN/60)*(360/12)-90,$center,$hpoint3)
$hourpoint[1][0] = $hm1[0]
$hourpoint[1][1] = $hm1[1]
$hourpoint[2][0] = $hm2[0]
$hourpoint[2][1] = $hm2[1]
$hourpoint[3][0] = $hm3[0]
$hourpoint[3][1] = $hm3[1]
_GDIPlus_GraphicsFillPolygon($effg,$hourpoint,$hourb1)
EndIf
EndIf
WEnd
_GDIPlus_Shutdown()

;#FUNCTION#==================================================================================================================
; Name...........: _PointRotate
; Description ...: Returns the new cordinates of a point.
; Syntax.........: _PointRotate($r_Angle, $c_center, $c_point)
; Parameters ....: $r_Angle - The angle to use
; $c_center - The array[2] containing center cordinates
; $c_point - The array[2] containing the point cordinates
; Return values .: Success - Returns an array[2] containing the cordinates of the new point.
;
; Author ........: Dragon[ITA]
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
;============================================================================================================================
Func _PointRotate($r_Angle, ByRef Const $c_center, ByRef Const $c_point)
Local $PI = 3.1415926535897932384626433832795
$dist = Sqrt(($c_point[0]-$c_center[0])^2+($c_point[1]-$c_center[1])^2)
$a_Angle = ACos(($c_point[0]-$c_center[0])/$dist)*180/$pi
If $c_point[1]-$c_center[1] < 0 Then
$a_Angle = -$a_Angle
EndIf
Local $c_pointf[2] = [Round($dist*Cos(($r_Angle+$a_Angle)*$pi/180))+$c_Center[0],Round($dist*Sin(($r_Angle+$a_Angle)*$pi/180))+$c_center[1]]
Return $c_pointf
EndFunc ;==>_PointRotate

Func _AntiAlias($hGraphics, $iMode)
Local $aResult

$aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode)
If @error Then Return SetError(@error, @extended, False)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_AntiAlias


EDIT: Dimenticavo... provate anche a premere destro sulla finestra x cambiare i colori...

Edited by Dragon[ITA] - 4/5/2010, 21:47
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 12:00     +1   -1




lol l'orologio puzza ... e nessuno mi caga ._.
 
Top
xdmisterx
CAT_IMG Posted on 5/5/2010, 12:17     +1   -1




oddio che figata! xD
 
Top
ACIDBURN16
CAT_IMG Posted on 5/5/2010, 12:45     +1   -1




Bell' orologio complimenti ( mi piace troppo xd).
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 12:52     +1   -1




grazie ^^
 
Top
Gianlu-thebest
CAT_IMG Posted on 5/5/2010, 13:06     +1   -1




OMG Troppo FIGOOOOO

o.O
 
Top
-Anubi-
CAT_IMG Posted on 5/5/2010, 13:20     +1   -1




Peccato che quell'orologio sia fra i file di esempio in Autoit xD
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 13:33     +1   -1




peccato che sia una altro orologio :angry:

e soprattutto quello dell'esempio sta sul desktop e nn va la lancetta delle ore

e non ha la funzione "_PointRotate" fatta da me personalmente

e non ha le animazioni

e non puoi cambiare i colori

<_< mi sento offeso

Da notare la differenza <_<
SPOILER (click to view)
#include <gdiplus.au3>
#include <winapi.au3>
#include <guiconstantsex.au3>
#include <windowsconstants.au3>

Opt("MustDeclareVars", 1)

; ===============================================================================================================================
; Description ...: Simple clock using layered windows
; Author ........: Paul Campbell (PaulIA)
; Notes .........:
; ===============================================================================================================================

; ===============================================================================================================================
; Global constants
; ===============================================================================================================================

Global Const $iCenter = 200
Global Const $iDotOpacity = 250
Global Const $iHourRad = 140
Global Const $iMinRad = 200
Global Const $iOpacity = 128
Global Const $nPI = 3.1415926535897932384626433832795
Global Const $iRadius = 200
Global Const $iSecRad = 200
Global Const $iTickLen = 0.02

Global Const $AC_SRC_ALPHA = 1

Global Enum $eScrDC=0, $eMemDC, $eBitmap, $eWidth, $eHeight, $eGraphic, $ePen, $eCap, $eBrush, $eFormat, $eFamily, $eFont, $eLayout, $eLast

; ===============================================================================================================================
; Global variables
; ===============================================================================================================================

Global $hDial, $hTime, $hHour, $hMin, $hSec, $hDot, $aTime, $aHour, $aMin, $aSec, $aCurr[3][2], $aLast[3][2]

; ===============================================================================================================================
; Main
; ===============================================================================================================================

ClockInit()
DialDraw ()
Draw ()
DotDraw ()
ClockLoop()
ClockDone()

; ===============================================================================================================================
; Finalize clock
; ===============================================================================================================================
Func ClockDone()
; Finalize GDI+ resources
TimeDone()
HourDone()
MinDone ()
SecDone ()

; Finalize GDI+ library
_GDIPlus_Shutdown()
EndFunc

; ===============================================================================================================================
; Initialize clock
; ===============================================================================================================================
Func ClockInit()
Local $iX, $iY

; Calculate the dial frame caption size
$iX = -(_WinAPI_GetSystemMetrics($SM_CXFRAME))
$iY = -(_WinAPI_GetSystemMetrics($SM_CYCAPTION) + _WinAPI_GetSystemMetrics($SM_CYFRAME))

; Allocate the window resources
$hDial = GUICreate("Clock", $iRadius * 2, $iRadius * 2, -1, -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetState()
$hTime = GUICreate("Time" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
GUISetState()
$hHour = GUICreate("Hour" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
GUISetState()
$hMin = GUICreate("Min" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
GUISetState()
$hSec = GUICreate("Sec" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
GUISetState()
$hDot = GUICreate("Dot" , $iRadius * 2, $iRadius * 2, $iX, $iY, 0, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hDial)
GUISetState()

; Initialize GDI+ library
_GDIPlus_Startup()

; Initialize GDI+ resources
TimeInit()
HourInit()
MinInit ()
SecInit ()

; Hook non client hit test message so we can move the clock
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
EndFunc

; ===============================================================================================================================
; Loop until user exits
; ===============================================================================================================================
Func ClockLoop()
do
Draw()
until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc

; ===============================================================================================================================
; Draw the center dot
; ===============================================================================================================================
Func DotDraw()
Local $aDot

$aDot = ResourceInit($iRadius * 2, $iRadius * 2)
_GDIPlus_GraphicsFillEllipse($aDot[$eGraphic], $iRadius-10, $iRadius-10, 20, 20)
ResourceSet ($hDot, $aDot, $iDotOpacity)
ResourceDone($aDot)
EndFunc

; ===============================================================================================================================
; Draw the clock elements
; ===============================================================================================================================
Func Draw()
; Calculate current time element position
$aLast = $aCurr
$aCurr[0][0] = $iCenter + Cos(TimeToRadians("sec" )) * $iSecRad
$aCurr[0][1] = $iCenter - Sin(TimeToRadians("sec" )) * $iSecRad
$aCurr[1][0] = $iCenter + Cos(TimeToRadians("min" )) * $iMinRad
$aCurr[1][1] = $iCenter - Sin(TimeToRadians("min" )) * $iMinRad
$aCurr[2][0] = $iCenter + Cos(TimeToRadians("hour")) * $iHourRad
$aCurr[2][1] = $iCenter - Sin(TimeToRadians("hour")) * $iHourRad

; Draw time elements
TimeDraw()
HourDraw()
MinDraw ()
SecDraw ()
EndFunc

; ===============================================================================================================================
; Draw the clock dial
; ===============================================================================================================================
Func DialDraw()
Local $aDial, $hPen1, $hPen2, $iI, $iN, $iX1, $iY1, $iX2, $iY2

$aDial = ResourceInit($iRadius * 2, $iRadius * 2)
$hPen1 = _GDIPlus_PenCreate()
$hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 4)
for $iI = 0 to 2 * $nPI Step $nPI / 30
$iX1 = $iCenter + Cos($iI) * ($iRadius * (1.00 - $iTickLen))
$iY1 = $iCenter - Sin($iI) * ($iRadius * (1.00 - $iTickLen))
$iX2 = $iCenter + Cos($iI) * $iRadius
$iY2 = $iCenter - Sin($iI) * $iRadius
if Mod($iN, 5) = 0 then
_GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1, $iY1, $iX2, $iY2, $hPen2)
else
_GDIPlus_GraphicsDrawLine($aDial[$eGraphic], $iX1, $iY1, $iX2, $iY2, $hPen1)
endif
$iN += 1
next
_GDIPlus_PenDispose($hPen2)
_GDIPlus_PenDispose($hPen1)

ResourceSet ($hDial, $aDial)
ResourceDone($aDial)
EndFunc

; ===============================================================================================================================
; Finalize resources for the hour hand
; ===============================================================================================================================
Func HourDone()
_GDIPlus_PenDispose($aHour[$ePen])
_GDIPlus_ArrowCapDispose($aHour[$eCap])
ResourceDone($aHour)
EndFunc

; ===============================================================================================================================
; Draw the hour hand
; ===============================================================================================================================
Func HourDraw()
if ($aLast[2][0] = $aCurr[2][0]) and ($aLast[2][1] = $aCurr[2][1]) then Return
_GDIPlus_GraphicsDrawLine($aHour[$eGraphic], $iCenter, $iCenter, $aCurr[2][0], $aCurr[2][1], $aHour[$ePen])
ResourceSet($hHour, $aHour)
EndFunc

; ===============================================================================================================================
; Initialize resources for the hour hand
; ===============================================================================================================================
Func HourInit()
$aHour = ResourceInit($iRadius * 2, $iRadius * 2)
$aHour[$ePen] = _GDIPlus_PenCreate(0xFFFF00FF)
$aHour[$eCap] = _GDIPlus_ArrowCapCreate($iHourRad / 2, 8)
_GDIPlus_PenSetCustomEndCap($aHour[$ePen], $aHour[$eCap])
EndFunc

; ===============================================================================================================================
; Finalize resources for the minute hand
; ===============================================================================================================================
Func MinDone()
_GDIPlus_PenDispose($aMin[$ePen])
_GDIPlus_ArrowCapDispose($aMin[$eCap])
ResourceDone($aMin)
EndFunc

; ===============================================================================================================================
; Draw the minute hand
; ===============================================================================================================================
Func MinDraw()
if ($aLast[1][0] = $aCurr[1][0]) and ($aLast[1][1] = $aCurr[1][1]) then Return
_GDIPlus_GraphicsFillRect($aMin[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
_GDIPlus_GraphicsDrawLine($aMin[$eGraphic], $iCenter, $iCenter, $aCurr[1][0], $aCurr[1][1], $aMin[$ePen])
ResourceSet($hMin, $aMin)
EndFunc

; ===============================================================================================================================
; Initialize resources for the minute hand
; ===============================================================================================================================
Func MinInit()
$aMin = ResourceInit($iRadius * 2, $iRadius * 2)
$aMin[$ePen] = _GDIPlus_PenCreate(0xFFFF0000)
$aMin[$eCap] = _GDIPlus_ArrowCapCreate($iMinRad / 2, 8)
_GDIPlus_PenSetCustomEndCap($aMin[$ePen], $aMin[$eCap])
EndFunc

; ===============================================================================================================================
; Finalize resources for the second hand
; ===============================================================================================================================
Func SecDone()
_GDIPlus_PenDispose($aSec[$ePen])
ResourceDone($aSec)
EndFunc

; ===============================================================================================================================
; Draw the second hand
; ===============================================================================================================================
Func SecDraw()
if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
_GDIPlus_GraphicsFillRect($aSec[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
_GDIPlus_GraphicsDrawLine($aSec[$eGraphic], $iCenter, $iCenter, $aCurr[0][0], $aCurr[0][1], $aSec[$ePen])
ResourceSet($hSec, $aSec)
EndFunc

; ===============================================================================================================================
; Initialize resources for the second hand
; ===============================================================================================================================
Func SecInit()
$aSec = ResourceInit($iRadius * 2, $iRadius * 2)
$aSec[$ePen] = _GDIPlus_PenCreate(0xFF000000)
EndFunc

; ===============================================================================================================================
; Finalize drawing resources
; ===============================================================================================================================
Func ResourceDone(ByRef $aInfo)
_GDIPlus_GraphicsDispose($aInfo[$eGraphic])
_WinAPI_ReleaseDC (0, $aInfo[$eScrDC])
_WinAPI_DeleteObject($aInfo[$eBitmap])
_WinAPI_DeleteDC ($aInfo[$eMemDC ])
EndFunc

; ===============================================================================================================================
; Initialize bitmap resources
; ===============================================================================================================================
Func ResourceInit($iWidth, $iHeight)
Local $aInfo[$eLast + 1]

$aInfo[$eScrDC ] = _WinAPI_GetDC(0)
$aInfo[$eMemDC ] = _WinAPI_CreateCompatibleDC($aInfo[$eScrDC])
$aInfo[$eBitmap ] = _WinAPI_CreateCompatibleBitmap($aInfo[$eScrDC], $iWidth, $iHeight)
_WinAPI_SelectObject($aInfo[$eMemDC], $aInfo[$eBitmap])
$aInfo[$eWidth ] = $iWidth
$aInfo[$eHeight ] = $iHeight
$aInfo[$eGraphic] = _GDIPlus_GraphicsCreateFromHDC($aInfo[$eMemDC])
_GDIPlus_GraphicsFillRect($aInfo[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
Return $aInfo
EndFunc

; ===============================================================================================================================
; Update layered window with resource information
; ===============================================================================================================================
Func ResourceSet($hGUI, ByRef $aInfo, $iAlpha=-1)
Local $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

if $iAlpha = -1 then $iAlpha = $iOpacity
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize )
DllStructSetData($tSize, "X", $aInfo[$eWidth ])
DllStructSetData($tSize, "Y", $aInfo[$eHeight])
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend )
DllStructSetData($tBlend, "Alpha" , $iAlpha )
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $aInfo[$eScrDC], 0, $pSize, $aInfo[$eMemDC], $pSource, 0, $pBlend, $ULW_ALPHA)
EndFunc

; ===============================================================================================================================
; Finalize resources for the digital time
; ===============================================================================================================================
Func TimeDone()
_GDIPlus_FontDispose ($aTime[$eFont ])
_GDIPlus_FontFamilyDispose ($aTime[$eFamily])
_GDIPlus_StringFormatDispose($aTime[$eFormat])
_GDIPlus_BrushDispose ($aTime[$eBrush ])
ResourceDone($aTime)
EndFunc

; ===============================================================================================================================
; Draw the digital time
; ===============================================================================================================================
Func TimeDraw()
Local $sString, $aSize

if ($aLast[0][0] = $aCurr[0][0]) and ($aLast[0][1] = $aCurr[0][1]) then Return
$sString = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
$aSize = _GDIPlus_GraphicsMeasureString($aTime[$eGraphic], $sString, $aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat])
DllStructSetData($aTime[$eLayout], "X", $iRadius - (DllStructGetData($aSize[0], "Width") / 2))
DllStructSetData($aTime[$eLayout], "Y", $iRadius / 3)
_GDIPlus_GraphicsFillRect($aTime[$eGraphic], 0, 0, $iRadius * 2, $iRadius * 2)
_GDIPlus_GraphicsDrawStringEx($aTime[$eGraphic], $sString, $aTime[$eFont], $aTime[$eLayout], $aTime[$eFormat], $aTime[$eBrush])
ResourceSet($hTime, $aTime)
EndFunc

; ===============================================================================================================================
; Initialize resources for the digital time
; ===============================================================================================================================
Func TimeInit()
$aTime = ResourceInit($iRadius * 2, $iRadius * 2)
$aTime[$eBrush ] = _GDIPlus_BrushCreateSolid(0xFF008080)
$aTime[$eFormat] = _GDIPlus_StringFormatCreate()
$aTime[$eFamily] = _GDIPlus_FontFamilyCreate("Arial")
$aTime[$eFont ] = _GDIPlus_FontCreate($aTime[$eFamily], 24, 1)
$aTime[$eLayout] = _GDIPlus_RectFCreate(0, 0, $iRadius * 2, 40)
EndFunc

; ===============================================================================================================================
; Convert time value to radians
; ===============================================================================================================================
Func TimeToRadians($sTimeType)
Switch $sTimeType
case "sec"
Return ($nPI / 2) - (@SEC * ($nPI / 30))
case "min"
Return ($nPI / 2) - (@MIN * ($nPI / 30)) - (Int(@SEC / 10) * ($nPI / 180))
case "hour"
Return ($nPI / 2) - (@HOUR * ($nPI / 6 )) - (@MIN / 12) * ($nPI / 30)
EndSwitch
EndFunc

; ===============================================================================================================================
; Handle the WM_NCHITTEST message so our window can be dragged
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if $hWnd = $hDial then Return $HTCAPTION
EndFunc
 
Top
MHack
CAT_IMG Posted on 5/5/2010, 13:38     +1   -1




Ma è troppo gordo quell'orologio! Complimenti, proprio un bel lavoro ;)
 
Top
-Anubi-
CAT_IMG Posted on 5/5/2010, 13:41     +1   -1




Ops, sembrava uguale xD
 
Top
Dragon[ITA]
CAT_IMG Posted on 5/5/2010, 13:43     +1   -1




lol -_-
 
Top
10 replies since 4/5/2010, 20:30   174 views
  Share