Page 1 sur 1

fermeture fenetre animée !!

Publié : ven. 09/avr./2004 11:17
par Invité
de Dobro !
voila une petite fonction toute simple mais qui met du dynamisme
dans la fermeture de fenetres

cela donnera surement des idees a certains d'entre vous !

Declare winfx(type.s)


; on ouvre une fenetre
WindowID = OpenWindow(1, 50, 50, 200, 200, #PB_Window_SystemMenu , "hello")
WindowID = WindowID(1)
Repeat
event=WaitWindowEvent()

Until event=#PB_Event_CloseWindow
; *******************************


; ici on appel la fonction qui fait partir la fenetre
;winfx("larg")
;winfx("haut")
;winfx("elast")
;winfx("elast2")
winfx("go_gauche")
;winfx("go_droite")

;winfx("go_haut")
;winfx("go_bas")

Procedure winfx(type.s)
If vitesse<1
vitesse=1
EndIf
If vitesse>2
vitesse=2
EndIf

winx = WindowX()
winy = WindowY()
winhaut = WindowHeight()
winlarg = WindowWidth()

;la fenetre retreci la largeur
If type.s ="larg"
For cont=winlarg To 1 Step -2
ResizeWindow(cont, winhaut)
Next cont
EndIf

;la fenetre retreci la hauteur
If type.s ="haut"
For cont=winhaut To 1 Step -2
ResizeWindow(winlarg,cont)
Next cont
EndIf

;la fenetre elactic
If type.s ="elast"
For cont=winhaut To 1 Step -2
ResizeWindow(winlarg,cont)
Next cont
For cont=1 To winhaut
ResizeWindow(winlarg,cont)
Next cont
For cont=winhaut To 1 Step -2
ResizeWindow(winlarg,cont)
Next cont
EndIf
;la fenetre elactic2
For p=1 To 2
If type.s ="elast2"
For cont=winhaut To 1 Step -2
ResizeWindow(winlarg,cont)
Next cont
For cont=1 To winhaut Step 2
ResizeWindow(winlarg,cont)
Next cont

For cont=winhaut To 1 Step -2
ResizeWindow(winlarg,cont)
Next cont
EndIf
Next p

;la fenetre part a gauche
If type.s ="go_gauche"
; un petit coup a droite
For cont=winx To winx+100 Step 1
MoveWindow(cont,winy)
Next cont

For cont=winx To 0 Step -2
MoveWindow(cont,winy)
Next cont
EndIf

;la fenetre part a droite

If type.s ="go_droite"
; un petit coup a gauche
For cont=winx To winx-100 Step -1
MoveWindow(cont,winy)
Next cont

For cont=winx To 1024 Step 2
MoveWindow(cont,winy)
Next cont
EndIf
;la fenetre part en bas
If type.s ="go_bas"
For cont=winy To 800 Step 1
MoveWindow(winx,cont)
Next cont
EndIf
;la fenetre part en haut
If type.s ="go_haut"
For cont=winy To 0 Step -2
MoveWindow(winx,cont)
Next cont
EndIf


EndProcedure
voila :D

Publié : ven. 09/avr./2004 12:31
par filperj
Excellent :lol:

Publié : ven. 09/avr./2004 15:57
par Oliv
génial :D

Publié : ven. 09/avr./2004 18:09
par Invité
de Dobro : Merci :D

Publié : ven. 09/avr./2004 23:19
par Le Soldat Inconnu
oui, j'ai me bien le léger retour en arrière de la fenêtre avant que celle ci aille se cacher. ça donne de la vitesse, c'est bien trouvé :D
il ne manque la fenêtre qui se casse en faisant des bond sur la barre des taches.
tient, ça me plait cette idée à la c.., je vais m'amuser à le faire

Publié : sam. 10/avr./2004 9:07
par Invité
de Dobro : :D oui c'est cool


on peut aussi faire effectuer a la fenetre un rond avant de partir

mais le mieux serai de faire un bloc image de la fenetre avant quelle ne
disparaisse pour faire reaficher ce bloc image a la place de cette
fenetre de facon a pouvoir le deformer comme ont veut
style "rouler avant de partir" ; "ecraser l'image fenetre avant de partir" ect...

mais je ne maitrise pas assez le Pure pour faire ça .

ça risque de me prendre des mois pour m'y remetre,et je sais pas si j'ai le courage alors si ça t'amuse !!!
:D

en fait j'ai pompé un peut l'idee sur un soft qui s'appel WindowFX
qui sert a donner de l'animation au fenetre du system !!!!

Publié : sam. 10/avr./2004 11:00
par Le Soldat Inconnu
oui, ça m'amuse, je vais esayer de faire une lib et voius filerai le code, comme ça vous pourez le compléter et etc...

Publié : sam. 10/avr./2004 11:20
par Invité
de Dobro : COOOOOOOOOOOOOOOOOOOOOOOOL :D


a tu remarquer que l'on peut appeler la fonctionavant que la fenetre
s'affiche !!

WindowID = OpenWindow(1, 50, 50, 200, 200, #PB_Window_SystemMenu , "hello")
WindowID = WindowID(1)
winfx("go_gauche") <------------------ ici

Ce qui permet d'envisager des animation avant ouverture !!! :D

Publié : sam. 10/avr./2004 16:07
par Le Soldat Inconnu
oui, pour le moment, je travaille sur la fermeture de la fenêtre, je verrai après pour l'ouverture ;)

j'ai fait ça pour le moment :

Code : Tout sélectionner

Global AW_Taille_Ecran_X.l, AW_Taille_Ecran_Y.l, AW_Taille_Fen_X.l, AW_Taille_Fen_Y.l

Enumeration
  #AnimateWindow_Image
  #AnimateWindow_Image2
  #AnimateWindow
EndEnumeration

Procedure Haut()
  Y = WindowY()
  For n = 1 To 25
    MoveWindow(WindowX(), Y - Int((1.5 * Pow(n / 25, 2) - 0.02 * n) * AW_Taille_Ecran_Y))
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
EndProcedure

Procedure Droite()
  X = WindowX()
  For n = 1 To 25
    MoveWindow(X + Int((1.5 * Pow(n / 25, 2) - 0.02 * n) * AW_Taille_Ecran_X), WindowY())
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
EndProcedure

Procedure Bas()
  Y = WindowY()
  For n = 1 To 25
    MoveWindow(WindowX(), Y + Int((1.5 * Pow(n / 25, 2) - 0.02 * n) * AW_Taille_Ecran_Y))
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
EndProcedure

Procedure Gauche()
  X = WindowX()
  For n = 1 To 25
    MoveWindow(X - Int((1.5 * Pow(n / 25, 2) - 0.02 * n) * AW_Taille_Ecran_X), WindowY())
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
EndProcedure

Procedure Fermeture_H()
  X = WindowX()
  Y = WindowY()
  
  For n = 1 To 24
    ResizeWindow(AW_Taille_Fen_X - AW_Taille_Fen_X * n / 24, AW_Taille_Fen_Y)
    MoveWindow(X + AW_Taille_Fen_X * n / 48, Y)
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
  
EndProcedure

Procedure Fermeture_V()
  X = WindowX()
  Y = WindowY()
  
  For n = 1 To 24
    ResizeWindow(AW_Taille_Fen_X, AW_Taille_Fen_Y - AW_Taille_Fen_Y * n / 24)
    MoveWindow(X, Y + AW_Taille_Fen_Y * n / 48)
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
  
EndProcedure

Procedure Fermeture_T()
  X = WindowX()
  Y = WindowY()
  
  For n = 1 To 24
    ResizeWindow(AW_Taille_Fen_X - AW_Taille_Fen_X * n / 24, AW_Taille_Fen_Y - AW_Taille_Fen_Y * n / 24)
    MoveWindow(X + AW_Taille_Fen_X * n / 48, Y + AW_Taille_Fen_Y * n / 48)
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
EndProcedure

Procedure Interieur()
  For n = 20 To 1 Step - 1
    
    Region1 = CreateRectRgn_(0, 0, AW_Taille_Fen_X, AW_Taille_Fen_Y)
    Region2 = CreateRectRgn_(AW_Taille_Fen_X * n / 40, AW_Taille_Fen_Y * n / 40, AW_Taille_Fen_X - AW_Taille_Fen_X * n / 40, AW_Taille_Fen_Y - AW_Taille_Fen_Y * n / 40)
    
    CombineRgn_(Region1, Region1, Region2, #RGN_DIFF)
    
    SetWindowRgn_(WindowID(), Region1, #True)
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
    
    DeleteObject_(Region1)
    DeleteObject_(Region2)
    
  Next
EndProcedure

Procedure Saut()
  ; taille de la zone de l'écran utilisable (sans la barre des taches)
  SystemParametersInfo_(#SPI_GETWORKAREA, 0, @Taille_Ecran.RECT, 0)
  
  ; la fenêtre tombe
  Y = WindowY()
  Chute = Taille_Ecran\Bottom - Y - AW_Taille_Fen_Y
  Pas = Pow(Chute * 600 / AW_Taille_Ecran_Y, 0.5)
  For n = 1 To Pas
    MoveWindow(WindowX(), Y + Chute * n / Pas)
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
  
  ; la fenêtre fait un premier bond
  Pas = Pas * 1.5
  Chute = Chute * 0.4
  Y = WindowY()
  X = WindowX()
  For n = 1 To Pas * 2
    MoveWindow(X + Chute * n / Pas, Y - Int((n / Pas - Pow(n / Pas, 2)) * Chute * 4))
    UpdateWindow_(WindowID(#AnimateWindow))
    Delay(1)
  Next
  
EndProcedure

Procedure Explose()
  ; taille et position de la fenêtre
  GetWindowRect_(WindowID(#AnimateWindow), Fen.rect)
  
  For n = 1 To 3
    OpenWindow(#AnimateWindow + n, Fen\Left, Fen\Top, AW_Taille_Fen_X, AW_Taille_Fen_Y, #PB_Window_BorderLess | #PB_Window_Invisible, "")
    SetWindowLong_(WindowID(#AnimateWindow + n), #GWL_EXSTYLE, GetWindowLong_(WindowID(#AnimateWindow + n), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) ; choix de la barre d'outil réduite
    If CreateGadgetList(WindowID(#AnimateWindow + n))
      ImageGadget(n, 0, 0, AW_Taille_Fen_X, AW_Taille_Fen_Y, UseImage(#AnimateWindow_Image))
    EndIf
    ShowWindow_(WindowID(#AnimateWindow + n), #SW_SHOW)
  Next
  
  ; on applique les masques au fenêtre
  Region0 = CreateRectRgn_(0, 0, AW_Taille_Fen_X / 2, AW_Taille_Fen_Y / 2)
  SetWindowRgn_(WindowID(#AnimateWindow), Region0, #True)
  
  Region1 = CreateRectRgn_(AW_Taille_Fen_X, 0, AW_Taille_Fen_X / 2, AW_Taille_Fen_Y / 2)
  SetWindowRgn_(WindowID(#AnimateWindow + 1), Region1, #True)
  
  Region2 = CreateRectRgn_(AW_Taille_Fen_X, AW_Taille_Fen_Y, AW_Taille_Fen_X / 2, AW_Taille_Fen_Y / 2)
  SetWindowRgn_(WindowID(#AnimateWindow + 2), Region2, #True)
  
  Region3 = CreateRectRgn_(0, AW_Taille_Fen_Y, AW_Taille_Fen_X / 2, AW_Taille_Fen_Y / 2)
  SetWindowRgn_(WindowID(#AnimateWindow + 3), Region3, #True)
  
  DeleteObject_(Region0)
  DeleteObject_(Region1)
  DeleteObject_(Region2)
  DeleteObject_(Region3)
  
  ; on écarte les morceaux
  X = WindowX()
  Y = WindowY()
  For n = 1 To 30
    Coef.f = Pow(n, 2) / 900
  
    UseWindow(#AnimateWindow)
    MoveWindow(X - AW_Taille_Ecran_X * Coef, Y - AW_Taille_Ecran_Y * Coef)
    UpdateWindow_(WindowID(#AnimateWindow))
    
    UseWindow(#AnimateWindow + 1)
    MoveWindow(X + AW_Taille_Ecran_X * Coef, Y - AW_Taille_Ecran_Y * Coef)
    UpdateWindow_(WindowID(#AnimateWindow + 1))
    
    UseWindow(#AnimateWindow + 2)
    MoveWindow(X + AW_Taille_Ecran_X * Coef, Y + AW_Taille_Ecran_Y * Coef)
    UpdateWindow_(WindowID(#AnimateWindow + 2))
    
    UseWindow(#AnimateWindow + 3)
    MoveWindow(X - AW_Taille_Ecran_X * Coef, Y + AW_Taille_Ecran_Y * Coef)
    UpdateWindow_(WindowID(#AnimateWindow + 3))
    
    Delay(1)
  Next
  
EndProcedure




Procedure.l Capture(WindowID.l)
  ; Cette procedure permet de créer une nouvelle fenêtre représentant la fenêtre à animée
  
  ; taille et position de la fenêtre
  GetWindowRect_(WindowID, Fen.rect)
  AW_Taille_Fen_X = Fen\Right - Fen\Left
  AW_Taille_Fen_Y = Fen\Bottom - Fen\Top
  
  ; on fait une impression d'acran
  DC = GetDC_(0)
  CreateImage(#AnimateWindow_Image, AW_Taille_Fen_X, AW_Taille_Fen_Y)
  Dessin = StartDrawing(ImageOutput())
    bitblt_(Dessin, 0, 0, AW_Taille_Fen_X, AW_Taille_Fen_Y, DC, Fen\Left, Fen\Top, #SRCCOPY)
  StopDrawing()
  ReleaseDC_(0, DC)
  
  ; on créé la nouvelle fenêtre
  OpenWindow(#AnimateWindow, Fen\Left, Fen\Top, AW_Taille_Fen_X, AW_Taille_Fen_Y, #PB_Window_BorderLess  | #PB_Window_Invisible, "")
  SetWindowLong_(WindowID(), #GWL_EXSTYLE, GetWindowLong_(WindowID(), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW) ; choix de la barre d'outil réduite
  If CreateGadgetList(WindowID(#AnimateWindow + num))
    ImageGadget(0, 0, 0, AW_Taille_Fen_X, AW_Taille_Fen_Y, UseImage(#AnimateWindow_Image))
  EndIf
  ShowWindow_(WindowID(), #SW_SHOW) ; montre la fenêtre
  
  ProcedureReturn WindowID(#AnimateWindow)
EndProcedure

ProcedureDLL AnimateWindow(Window.l, Type.l) ; Animer la fermeture de la fenêtre
  ; Cette fonction permet d'animer la fermeture de la fenêtre
  ; Window : numéro de la fenêtre
  ; Type : numéro de l'animation, Type peut prendre les valeur suivante
  ; 0 = la fenêtre se sauve par le haut de l'écran
  ; 1 = la fenêtre se sauve par la droite de l'écran
  ; 2 = la fenêtre se sauve par le bas de l'écran
  ; 3 = la fenêtre se sauve par la gauche de l'écran
  ; 4 = fermeture de la fenêtre horizontalement
  ; 5 = fermeture de la fenêtre verticalement
  ; 6 = fermeture de la fenêtre horizonatlement et verticalement
  ; 7 = la fenêtre disparait de l'intérieur
  ; 8 = la fenêtre quitte l'écran en faisant des bonds sur le bas de l'écran
  ; 9 = on explose la fenêtre en 4 partie
  
  Capture(WindowID(Window))
  
  ; on ferme l'ancienne fenêtre
  CloseWindow(Window)
  
  ; on récupère la taille de l'écran
  AW_Taille_Ecran_X = GetSystemMetrics_(#SM_CXSCREEN)
  AW_Taille_Ecran_Y = GetSystemMetrics_(#SM_CYSCREEN)
  
  UseWindow(#AnimateWindow)
  
  ; on anime la nouvelle fenêtre
  Select Type
    Case 0
      Haut()
    Case 1
      Droite()
    Case 2
      Bas()
    Case 3
      Gauche()
    Case 4
      Fermeture_H()
    Case 5
      Fermeture_V()
    Case 6
      Fermeture_T()
    Case 7
      Interieur()
    Case 8
      Saut()
    Case 9
      Explose()
  EndSelect
  
EndProcedure










;- Test

OpenWindow(0, 200, 100, 300, 200, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget, "Test")

Repeat
  Event = WaitWindowEvent()
Until Event = #WM_Close

AnimateWindow(0, 9)
End

Publié : sam. 10/avr./2004 16:14
par Invité
super bien !!

(bien plus "propre" que ce que j'avais pondu :)

Publié : sam. 10/avr./2004 16:55
par Chris
Pour info, tu sais qu'il y a une Api qui fait à peu près ce genre de truc?

J'avais commencé un bout de code, mais jamais fini.

Je le poste tel quel.

Code : Tout sélectionner

;/Constantes Window
Enumeration
  #Window_0
EndEnumeration

;/Constantes Gadget
Enumeration
  #Btn_Quit
EndEnumeration

;AW_SLIDE         Uses slide animation. 
;                 By Default, roll animation is used. 
;                 This flag is ignored when used with AW_CENTER. 
;AW_ACTIVATE      Activates the window. Do not use This value with AW_HIDE. 
;AW_BLEND         Uses a fade effect. This flag can be used only If hwnd is a top-level window. 
;AW_HIDE          Hides the window. By Default, the window is shown. 
;AW_CENTER        Makes the window appear To collapse inward 
;                 If AW_HIDE is used Or expand outward 
;                 If the AW_HIDE is not used. 
;                 the various direction flags have no effect. 
;AW_HOR_POSITIVE  Animates the window from left To right. 
;                 This flag can be used with roll Or slide animation. 
;                 It is ignored when used with AW_CENTER Or AW_BLEND.
;AW_HOR_NEGATIVE  Animates the window from right To left. 
;                 This flag can be used with roll Or slide animation. 
;                 It is ignored when used with AW_CENTER Or AW_BLEND.
;AW_VER_POSITIVE  Animates the window from top To bottom. 
;                 This flag can be used with roll Or slide animation. 
;                 It is ignored when used with AW_CENTER Or AW_BLEND. 
;AW_VER_NEGATIVE  Animates the window from bottom To top. 
;                 This flag can be used with roll Or slide animation. 
;                 It is ignored when used with AW_CENTER Or AW_BLEND. 

#CloseTopLeft     = #AW_HIDE|#AW_VER_POSITIVE|#AW_HOR_POSITIVE
#CloseTopRight    = #AW_HIDE|#AW_VER_POSITIVE|#AW_HOR_NEGATIVE
#CloseBottomLeft  = #AW_HIDE|#AW_VER_NEGATIVE|#AW_HOR_POSITIVE
#CloseBottomRight = #AW_HIDE|#AW_VER_NEGATIVE|#AW_HOR_NEGATIVE
#CloseCenter      = #AW_HIDE|#AW_CENTER

#OpenTopLeft      = #AW_ACTIVATE|#AW_VER_POSITIVE|#AW_HOR_POSITIVE
#OpenTopRight     = #AW_ACTIVATE|#AW_VER_POSITIVE|#AW_HOR_NEGATIVE
#OpenBottomLeft   = #AW_ACTIVATE|#AW_VER_NEGATIVE|#AW_HOR_POSITIVE
#OpenBottomRight  = #AW_ACTIVATE|#AW_VER_NEGATIVE|#AW_HOR_NEGATIVE
#OpenCenter       = #AW_ACTIVATE|#AW_CENTER

If OpenWindow(#Window_0, 300, 300, 300, 200, #PB_Window_SystemMenu|#PB_Window_Invisible, "Fenêtre 1",0)
  hWnd = WindowID(#Window_0)
  AnimateWindow_(hWnd,500,#OpenBottomRight)
  If CreateGadgetList(WindowID(#Window_0))
    ButtonGadget(#Btn_Quit, 100, 170, 100, 25, "Quitter")
  EndIf
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_EventGadget
        Select EventGadgetID()
          ;Case
          ;Case
          Case #Btn_Quit : quit = 1
        EndSelect
        ;Case
        ;Case
      Case #PB_EventCloseWindow
        quit = 1
    EndSelect
  Until quit = 1
  
  AnimateWindow_(hWnd,500,#AW_SLIDE|#CloseBottomRight)
  
  End
EndIf
Chris :)

Publié : sam. 10/avr./2004 16:55
par Le Soldat Inconnu
j'ai modifié le code, j'ai ajouté la fenêtre qui saute ;)

Publié : sam. 10/avr./2004 18:59
par Invité
Chris a écrit :Pour info, tu sais qu'il y a une Api qui fait à peu près ce genre de truc?
oui mais la c'est plus simple :D
moins long puisque ce sera une lib purebasic en une fonction !!!!
on pourra faire bien mieux a l'ouverture ou fermeture de la fenetre
avec des animation inscensé !!!! :D

et tous ça mis en boite par le soldat , ça le fait non ??? :D

Ps : geant les derniers rajout , l'explosion est vraiment bien reussi !!
faudroi pouvoir augmenter les fragments :D :D :D :D

tu crois que l'on peut rajouter du son ?
on enferme le son en dll puis on inclus ?
ou alors c'est trop lourd a gerer,une fonction qui aurai besoin que la dll
soit presente c'est pas geant , oublie :)

Publié : mer. 30/août/2006 17:14
par Backup
...................

Publié : mer. 30/août/2006 17:30
par Backup
.......................