Publié : ven. 24/nov./2006 11:43
@Kwai chang caine,
désolé de te relancer,
mais c'est bien çà que tu as besoin de faire - en gros ?
désolé de te relancer,
mais c'est bien çà que tu as besoin de faire - en gros ?
Forums PureBasic - Français
http://forums.purebasic.com/french/
Code : Tout sélectionner
; Code de Flype
; image transparente
; sur fenetre transparente
UsePNGImageDecoder()
Declare.l myCallback(hwnd.l, uMsg.l, wParam.l, lParam.l)
Global hImage.l = CatchImage(1, ?Image_01)
Global hImageList.l = ImageList_Create_(ImageWidth(1), ImageHeight(1), #ILC_COLOR32|#ILC_MASK, 1, 0)
ImageList_AddMasked_(hImageList, hImage, #Black)
If OpenWindow(0, 216, 0, 350, 250, "Test", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SetWindowCallback(@myCallback(), 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
ImageList_Destroy_(hImageList)
;-
;-
DataSection
Image_01: IncludeBinary "pb.png"
EndDataSection
;-
;-
Procedure.l myCallback(hwnd.l, uMsg.l, wParam.l, lParam.l)
Protected hdc.l, result.l = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_PAINT
hdc = BeginPaint_(hwnd, ps.PAINTSTRUCT)
PaintDesktop_(hdc)
ImageList_Draw_(hImageList, 0, hdc, 20, 20, #ILD_TRANSPARENT)
EndPaint_(hwnd, ps)
result = #True
Case #WM_SIZING, #WM_MOVING
InvalidateRect_(hwnd, 0, 1)
Case #WM_ERASEBKGND
result = #False
EndSelect
ProcedureReturn result
EndProcedure
;-
;-
c'est exactement ce à quoi je pense.Jacobus a écrit :Est-ce que par hasard ton fond d'écran ne serait pas noir?
Code : Tout sélectionner
;-
;-
Structure SPRITE
x.l
y.l
xSpeed.l
ySpeed.l
EndStructure
Structure SPRITELIST
hWindow.l
ImageList.l
width.l
height.l
nSprite.l
Sprite.SPRITE[99]
EndStructure
;-
;-
Macro SpriteList_Init(hSpriteList, Window, n, w = 48, h = 48)
hSpriteList\width = w
hSpriteList\height = h
hSpriteList\nSprite = n
hSpriteList\ImageList = ImageList_Create_(w, h, #ILC_COLOR32|#ILC_MASK, n, 0)
hSpriteList\hWindow = WindowID(Window)
SetTimer_(hSpriteList\hWindow, 1, 25, #Null)
EndMacro
Macro SpriteList_Free(hSpriteList)
KillTimer_(hSpriteList\hWindow, 1)
ImageList_Destroy_(hSpriteList\ImageList)
EndMacro
Macro SpriteList_Draw(hSpriteList, dc, index)
ImageList_Draw_(hSpriteList\ImageList, index, dc, hSpriteList\Sprite[index]\x, hSpriteList\Sprite[index]\y, #ILD_TRANSPARENT)
EndMacro
Macro SpriteList_Add(hSpriteList, index, ImageLabel, AlphaColor = #White)
CatchImage(image, ImageLabel)
hSpriteList\Sprite[index]\xSpeed = Random(400)
hSpriteList\Sprite[index]\ySpeed = Random(400)
ResizeImage(image, hSpriteList\width, hSpriteList\height)
ImageList_AddMasked_(hSpriteList\ImageList, ImageID(image), AlphaColor)
EndMacro
;-
;-
Global spr.SPRITELIST
;-
;-
Procedure.l myCallback(hwnd.l, uMsg.l, wParam.l, lParam.l)
Protected ps.PAINTSTRUCT, i.l, hdc.l, result.l = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_PAINT
hdc = BeginPaint_(hwnd, ps)
PaintDesktop_(hdc)
mx = WindowMouseX(1)
my = WindowMouseY(1)
For i = 0 To spr\nSprite
spr\Sprite[i]\x = mx + Random(10)
spr\Sprite[i]\y = my + Random(10)
spr\Sprite[i]\x + spr\Sprite[i]\xSpeed
spr\Sprite[i]\y + spr\Sprite[i]\ySpeed
SpriteList_Draw(spr, hdc, i)
Next
EndPaint_(hwnd, ps)
result = #True
Case #WM_MOUSEMOVE, #WM_MOVING, #WM_SIZING, #WM_TIMER ; Provoque un #WM_PAINT à la prochaine passe.
InvalidateRect_(hwnd, 0, 1)
Case #WM_ERASEBKGND
result = #False
EndSelect
ProcedureReturn result
EndProcedure
;-
;-
#Window = 1
UsePNGImageDecoder()
If OpenWindow(#Window, 0, 0, 640, 480, "SpriteList", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SpriteList_Init(spr, #Window, 20)
If spr\ImageList
SpriteList_Add(spr, 1, ?SPRITE1)
SpriteList_Add(spr, 2, ?SPRITE2)
SpriteList_Add(spr, 3, ?SPRITE3)
SpriteList_Add(spr, 4, ?SPRITE4)
SpriteList_Add(spr, 5, ?SPRITE5)
SpriteList_Add(spr, 6, ?SPRITE1)
SpriteList_Add(spr, 7, ?SPRITE2)
SpriteList_Add(spr, 8, ?SPRITE3)
SpriteList_Add(spr, 9, ?SPRITE4)
SpriteList_Add(spr, 10, ?SPRITE5)
SpriteList_Add(spr, 11, ?SPRITE1)
SpriteList_Add(spr, 12, ?SPRITE2)
SpriteList_Add(spr, 13, ?SPRITE3)
SpriteList_Add(spr, 14, ?SPRITE4)
SpriteList_Add(spr, 15, ?SPRITE5)
SpriteList_Add(spr, 16, ?SPRITE1)
SpriteList_Add(spr, 17, ?SPRITE2)
SpriteList_Add(spr, 18, ?SPRITE3)
SpriteList_Add(spr, 19, ?SPRITE4)
SetWindowCallback(@myCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndIf
SpriteList_Free(spr)
;-
;-
DataSection
SPRITE1: IncludeBinary "01.png"
SPRITE2: IncludeBinary "02.png"
SPRITE3: IncludeBinary "03.png"
SPRITE4: IncludeBinary "04.png"
SPRITE5: IncludeBinary "05.png"
EndDataSection
;-
;-
ha bah si !Jacobus a écrit :Est-ce que par hasard ton fond d'écran ne serait pas noir?