Publié : lun. 17/juil./2006 8:03
0% chez moi avec un P4 2,6
Code : Tout sélectionner
XIncludeFile "gdiplus.pbi"
Global GRAPH,Gdip
input.GdiplusStartupInput\GdiplusVersion = 1
GdiplusStartup(@Gdip,@input,0)
Procedure GetHombre(PosX.F,PosY.F,PosZ.F,*Hombre.POINTF)
LumX.F = 0
LumY.F = 0
LumZ.F = 300
mm.F = ( PosY - LumY ) / ( PosX - LumX )
nn.F = ( PosZ - LumZ ) / ( PosX - LumX )
qq.F = LumY - mm * LumX
pp.F = LumZ - nn * LumX
*Hombre\x = - pp / nn
*Hombre\y = mm * *Hombre\x + qq
EndProcedure
Procedure Gdip_Pen1(LineWidth.F,ARGB,StartCap,EndCap)
GdipCreatePen1(ARGB,LineWidth,2,@Pen)
GdipSetPenStartCap(Pen,StartCap)
GdipSetPenEndCap(Pen,EndCap)
ProcedureReturn Pen
EndProcedure
Procedure Gdip_SetFontFamily(fontName.s)
GdipCreateFontFamilyFromName(fontName,#Null,@Family)
ProcedureReturn Family
EndProcedure
Procedure Gdip_DrawText(Texte.s,x.F,y.F,Width.F,Height.F,Font,Brush)
R.RECTF\left = x : R\top = y
R\Width = Width : R\Height = Height
GdipDrawString(GRAPH,Texte,-1,Font,R, #Null,Brush)
EndProcedure
CreateImage(0,160,160);{
hdc = StartDrawing(ImageOutput(0))
GdipCreateFromHDC(hdc,@GRAPH)
GdipSetSmoothingMode(GRAPH,2)
GdipCreateSolidFill(MAKECOLOR(0,255,255,255),@Brush)
GdipFillRectangleI(GRAPH, Brush, 0, 0, 160, 160)
GdipDeleteBrush(Brush)
GdipCreateSolidFill(MAKECOLOR(160,0,0,255),@Brush)
GdipFillEllipseI(GRAPH, Brush, 3, 3, 154, 154)
GdipDeleteBrush(Brush)
GdipCreateSolidFill(MAKECOLOR(200,255,255,255),@Brush)
GdipFillEllipseI(GRAPH, Brush, 3, 3, 154, 154)
GdipDeleteBrush(Brush)
Pen = Gdip_Pen1(3,MAKECOLOR(200,50,50,50),2,2)
GdipDrawEllipseI(GRAPH,Pen,2,2,155,155)
GdipDeletePen(Pen)
GdipCreateSolidFill(MAKECOLOR(127,50,50,50),@Brush)
Family = Gdip_SetFontFamily("Arial")
GdipCreateFont(Family,18,1,2,@Font)
Gdip_DrawText("PureBasic",35,100,300,30,Font,Brush)
GdipDeleteFont(Font)
GdipCreateFont(Family,12,2,2,@Font)
Gdip_DrawText("Erix14",60,120,300,30,Font,Brush)
GdipDeleteFont(Font)
GdipDeleteFontFamily(Family)
GdipDeleteBrush(Brush)
Pen = Gdip_Pen1(3,MAKECOLOR(127,0,0,0),2,2)
For t=0 To 11
R.F = t * 30 - 90
GdipDrawLineI(GRAPH,Pen,80+Cos(R*(3.14159265/180))*76,80+Sin(R*(3.14159265/180))*76,80+Cos(R*(3.14159265/180))*70,80+Sin(R*(3.14159265/180))*70)
Next
GdipDeletePen(Pen)
GdipDeleteGraphics(GRAPH)
StopDrawing();}
Global BrushFond = CreatePatternBrush_(ImageID(0))
Global Size.SIZE
Size\cx = 160 : Size\cy = 160
;/
Procedure HorlogeCallback(WindowID, message, wParam, lParam)
Select message
Case #WM_CREATE
Case #WM_CLOSE ;{
DestroyWindow_(WindowID) ;}
Case #WM_DESTROY ;{
GdiplusShutdown(Gdip)
DeleteObject_(BrushFond)
PostQuitMessage_(0) ;}
Case #WM_CHAR ;{
Select wParam
Case #VK_ESCAPE
SendMessage_(WindowID,#WM_CLOSE,0,0)
EndSelect ;}
Case #WM_RBUTTONDOWN ;{
SendMessage_(WindowID,#WM_CLOSE,0,0) ;}
Case #WM_LBUTTONDOWN ;{
ReleaseCapture_()
SendMessage_(WindowID, #WM_NCLBUTTONDOWN, #HTCAPTION, 0);}
Case #WM_TIMER ;{
InvalidateRect_(WindowID, #Null, #False) ;}
Case #WM_PAINT ;{
hwndDC = BeginPaint_(WindowID,ps.PAINTSTRUCT)
hdc = CreateCompatibleDC_(hwndDC)
SelectObject_(hdc, ImageID(0))
GdipCreateFromHDC(hdc,@GRAPH)
GdipSetSmoothingMode(GRAPH,2)
SetRect_(rect.RECT,0,0,160,160)
FillRect_(hdc, rect, BrushFond)
;/
GetSystemTime_(@MonTime.SYSTEMTIME)
;/ H E U R E S
heure = MonTime\wHour % 12 + 2
ih.F = (360 * (heure * 60 + MonTime\wMinute)) / 720 - 90
PosX.F = 80+Cos(ih*(3.14159265/180))*45
PosY.F = 80+Sin(ih*(3.14159265/180))*45
GetHombre(PosX,PosY,6,@Hombre.POINTF)
Pen = Gdip_Pen1(4,MAKECOLOR(80,0,0,100),2,20)
GdipDrawLine(GRAPH,Pen,81,81,Hombre\x,Hombre\y)
GdipDeletePen(Pen)
Pen = Gdip_Pen1(4,MAKECOLOR(200,40,40,40),2,20)
GdipDrawLine(GRAPH,Pen,80,80,PosX,PosY)
GdipDeletePen(Pen)
;/ M I N U T E S
im.F = (360 * (MonTime\wMinute * 60 + MonTime\wSecond)) / 3600 - 90
PosX.F = 80+Cos(im*(3.14159265/180))*60
PosY.F = 80+Sin(im*(3.14159265/180))*60
GetHombre(PosX,PosY,8,@Hombre)
Pen = Gdip_Pen1(4,MAKECOLOR(80,0,0,100),2,20)
GdipDrawLine(GRAPH,Pen,81,81,Hombre\x,Hombre\y)
GdipDeletePen(Pen)
GdipDeletePen(Pen)
Pen = Gdip_Pen1(4,MAKECOLOR(200,40,40,40),2,20)
GdipDrawLine(GRAPH,Pen,80,80,PosX,PosY)
GdipDeletePen(Pen)
;/ S E C O N D E S
is.F = (360 * (MonTime\wSecond * 1000 + MonTime\wMilliseconds)) / 60000 - 90
PosX.F = 80+Cos(is*(3.14159265/180))*64
PosY.F = 80+Sin(is*(3.14159265/180))*64
GetHombre(PosX,PosY,10,@Hombre)
Pen = Gdip_Pen1(3,MAKECOLOR(80,0,0,100),2,2)
GdipDrawLine(GRAPH,Pen,81,81,Hombre\x,Hombre\y)
GdipDeletePen(Pen)
Pen = Gdip_Pen1(3,MAKECOLOR(200,255,0,0),2,2)
GdipDrawLine(GRAPH,Pen,80,80,PosX,PosY)
GdipDeletePen(Pen)
;/ C E N T R E
GdipCreateSolidFill(MAKECOLOR(80,0,0,100),@Brush)
GdipFillEllipseI(GRAPH, Brush, 74, 74, 14, 14)
GdipDeleteBrush(Brush)
GdipCreateSolidFill(MAKECOLOR(250,200,0,0),@Brush)
GdipFillEllipseI(GRAPH, Brush, 73, 73, 14, 14)
GdipDeleteBrush(Brush)
;/
ContextOffset.POINT
BlendMode.BLENDFUNCTION
BlendMode\SourceConstantAlpha = 246
BlendMode\AlphaFormat = 1
UpdateLayeredWindow_(WindowID, hwndDC, 0, @Size, hdc, @ContextOffset, 0, @BlendMode, 2)
GdipDeleteGraphics(GRAPH)
DeleteDC_(hdc)
EndPaint_(WindowID,ps) ;}
EndSelect
ProcedureReturn DefWindowProc_(WindowID, message, wParam, lParam)
EndProcedure
;- Debut Programme
;{/ Create Window
wc.WNDCLASSEX
wc\cbSize = SizeOf(WNDCLASSEX)
hInstance = GetModuleHandle_(#Null)
If GetClassInfoEx_(hInstance,@"Horloge",@wc) = 0
wc.WNDCLASSEX
wc\cbSize = SizeOf(WNDCLASSEX)
wc\style = #CS_HREDRAW|#CS_VREDRAW|#CS_BYTEALIGNWINDOW
wc\lpfnWndProc = @HorlogeCallback()
wc\hCursor = LoadCursor_(#Null,#IDC_ARROW)
wc\hInstance = hInstance
wc\lpszClassName = @"Horloge"
If RegisterClassEx_(@wc) = 0
End
EndIf
EndIf
hWndMain = CreateWindowEx_($00080088,"Horloge","Horloge",$96000000,50,50,160,160,0,0,hInstance,0)
InvalidateRect_(hWndMain, #Null, #False)
SetTimer_(hWndMain,0,40,0)
;}/
While GetMessage_(msg.MSG,#Null,0,0)
TranslateMessage_(msg)
DispatchMessage_(msg)
Wend
End
Voici les Widgets d'Opera : http://widgets.opera.com/time/Qu'entendez vous par widget ?
c'est notéNote mesquine : #Pi existe dans les résidents depuis la V4.
pas eu le temps en fait, j'ai surtout travaillé sur le wrapper GDI+.Sinon, Flype, la fonction GdipCreateBitmapFromResource, t'as réussi ?
erix14 a écrit :Merci Coolman de ta confiance. Surtout n'exécute pas PureSpy.exe, vu le nom moi j'aurais peur
Code : Tout sélectionner
*token = Gdiplus_New()
If OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
If Gdiplus_StartDrawing(WindowOutput(0))
Gdiplus_Ellipse(100, 100, 50, 50, RGB(255,0,0) )
Gdiplus_StopDrawing()
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Quitter = #True
EndIf
GdiplusShutdown(*token)
Code : Tout sélectionner
XIncludeFile "gdiplus.pbi"
If OpenWindow(0, 0, 0, 640, 480, "GdiPlus 1.0", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ShowCursor_(#False)
SetWindowColor(0, #Blue)
*token = Gdiplus_New()
GdipCreatePen1(ARGB(#White, 4), 30, 0, @*pen)
Repeat
Select WaitWindowEvent()
Case #WM_MOUSEMOVE
*gfx = Gdiplus_StartDrawing(WindowOutput(0))
For i = 0 To 5
GdipDrawEllipseI(*gfx, *pen, WindowMouseX(0)+Random(50)-25, WindowMouseY(0)+Random(50)-25, Random(60), 30)
Next
Gdiplus_StopDrawing()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
GdipDeletePen(*pen)
Gdiplus_Del(*token)
EndIf