PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → évènements minimiser fenêtre
évènements minimiser fenêtre
Débuté par Paul, 25 avr. 2006 23:58 - 4 réponses
Posté le 25 avril 2006 - 23:58
Bonjour,

est-il possible d'ajouter un évènement lorsque l'utilisateur clique sur le bouton pour minimiser la fenêtre... je ne veux pas utiliser la fonction "modification taille fenêtre", car elle se déclanche lorsque l'utilisiteur restaure la fenêtre également.

merci !
Posté le 26 avril 2006 - 10:51
Salut,

il n'y a pas d'événement qui gère cela directement.

Voici une solution:
Tu dois surclasser la fenêtre.

Voici comment faire:

//--Code de déclarations globales de ta fenêtre--
EXTERN "WinConst.wl"
CONSTANTE
GWL_WNDPROC = -4
SC_MINIMIZE = 0xF020
FIN
//modification de la procedure par défaut
defWindowProc est un entier
defWindowProc =
API("user32","SetWindowLongA",Handle(MaFenêtre),GWL_WNDPROC,&MaProcedure)

//--Code de fermeture de ta fenêtre--
//restauration de la procedure par défaut
SI defWindowProc <> 0ALORS
API("user32","SetWindowLongA",Handle(MaFenêtre),GWL_WNDPROC,defWindowProc)
defWindowProc = 0
FIN


//--Fonction locale MaProcedure--
PROCEDURE MaProcedure(hwnd,uMsg,wParam,lParam)
iRetour est un entier = -1
SI hwnd = Handle(MaFenêtre) ALORS
SI uMsg = WM_SYSCOMMAND ALORS
SI wParam = SC_MINIMIZE ALORS
Info("min")
//Ceci permet d'annuler le clic sur le bouton minimiser
iRetour = 0
FIN
FIN
FIN
SI iRetour = -1 ALORS
//Appel de la procedure normale
iRetour =
API("user32","CallWindowProcA",defWindowProc,hwnd,uMsg,wParam,lParam)
FIN
RENVOYER iRetour

La fonction MaProcedure te permet de décider ce qui arrivera lors d'un clic
sur le bouton minimiser. Si la valeur retournée par la procédure est 0, la
procédure normale d'un clic sur le bouton minimiser ne sera pas effectuée.

Mathieu
Posté le 26 avril 2006 - 10:52
Tout d'abord déclarer les constantes

//Specifies the type of resizing requested. This parameter can be one of the following values.
CONSTANT
SIZE_MAXHIDE= 0x0004
//Message is sent to all pop-up windows when some other window is
maximized.
SIZE_MAXIMIZED = 0x0003
//The window has been maximized.
SIZE_MAXSHOW = 0x0002
//Message is sent to all pop-up windows when some other window has
been restored to its former size.
SIZE_MINIMIZED = 0x0001
//The window has been minimized.
SIZE_RESTORED = 0x0000
//The window has been resized, but neither the SIZE_MINIMIZED nor
SIZE_MAXIMIZED value applies.

//lParam
//The low-order word of lParam specifies the new width of the client area.
//The high-order word of lParam specifies the new height of the client area.

FIN

Ensuite dans le code de déclaration des globales appeler la fonction sur evenemet

Evénement("ON_WM_SIZE", "*.", WM_SIZE)

puis créer la fonction ON_WM_SIZE

PROCEDURE ON_WM_SIZE(message,wParam,lParam)

SELON wParam
//Specifies the type of resizing requested. This parameter can be one of the following values.
CAS SIZE_MAXHIDE // ( 4 ou 0x0004 )
//Message is sent to all pop-up windows when some other window is
maximized.
Trace("SIZE_MAXHIDE largeur : "+PoidsFaible(lParam)+" Hauteur : "+PoidsFort(lParam))

CAS SIZE_MAXIMIZED // ( 3 ou 0x0003 )
//The window has been maximized. ( CLICK SUR LE BOUTON
D'AGRANDISSEMENT MAXI bouton de droite )
Trace("SIZE_MAXIMIZED largeur : "+PoidsFaible(lParam)+" Hauteur : "+PoidsFort(lParam))

CAS SIZE_MAXSHOW //( 2 ou 0x0002 )
//Message is sent to all pop-up windows when some other window
has been restored to its former size.
Trace("SIZE_MAXSHOW largeur : "+PoidsFaible(lParam)+" Hauteur : "+PoidsFort(lParam))

//
// MINIMISER C ICI
//
CAS SIZE_MINIMIZED // ( 1 ou 0x0001 )
//The window has been minimized. ( CLIC SUR LE BOUTON DE
REDUCTION bouton de gauche)
Trace("SIZE_MINIMIZED largeur : "+PoidsFaible(lParam)+" Hauteur : "+PoidsFort(lParam))

// ICI PoidsFaible(lParam) est toujours égal à 0 et PoidsFort(lParam)<=0
// j'ai toujours PoidsFort(lParam)=0 en MDI et PoidsFort(lParam) =-24 sans MDI

//
//

CAS SIZE_RESTORED // ( 0 ou 0x0000 )
//Changemet de taille manuel ( coin droite bas ) ou restoration
de la taille bouton du milieu .
Trace("SIZE_RESTORED largeur : "+PoidsFaible(lParam)+" Hauteur : "+PoidsFort(lParam))


//lParam
//The low-order word of lParam specifies the new width of the client area.
//The high-order word of lParam specifies the new height of the client area.
AUTRE CAS

FIN


bon Wdev

patrice
Posté le 26 avril 2006 - 14:56
Peut-être plus simple.
Possibilité 1:Avec l'événement resize.
SI tu teste l'état de ta fenêtre, tu sauras si l'action était un minimize.
Possibilité 2. Tu te crées un bouton minimise et maximise, comme dans l'exemple de Windev CRM.
Michel, Montréal
Posté le 26 avril 2006 - 18:46
Merci Patrice...

c'est ton exemple que j'utilise et ça fonctionne à merveille !

Paul