[Résolu] Problème redimensionner

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
David02
Messages : 46
Inscription : mer. 30/mars/2011 9:50

[Résolu] Problème redimensionner

Message par David02 »

J'aimerais savoir comment faire pour redimensionner un gadget quand on agrandi la fenêtre?

Voici le code utilisé pour le test:

Code : Tout sélectionner

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ProgressBar_0
EndEnumeration

OpenWindow(#Window_0, 220, 0, 600, 300, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_MinimizeGadget | #PB_window_maximizeGadget)
      ProgressBarGadget(#ProgressBar_0, 20, 200, 560, 60, 0, 10)
      

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
    Case #PB_Event_Menu
      Select EventGadget()
        Case #PB_Window_MaximizeGadget
          ResizeGadget(#ProgressBar_0, 300, #PB_Ignore, 1200, #PB_Ignore)
          EndSelect
    Case #PB_Event_CloseWindow
      fermer=#True
  EndSelect
Until fermer
Merci
Dernière modification par David02 le ven. 01/avr./2011 17:48, modifié 1 fois.
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Problème redimensionner

Message par venom »

avec les fonctions

Code : Tout sélectionner

WindowWidth(#Fenetre) 
WindowHeight(#Fenetre)





@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
David02
Messages : 46
Inscription : mer. 30/mars/2011 9:50

Re: Problème redimensionner

Message par David02 »

Oui mais c'est pour la fenêtre principale?
Moi ça serait d'agrandir le gadget (la progressbar) quand on appuie sur "Agrandir".
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Problème redimensionner

Message par venom »

et bien oui :D WindowWidth(#Fenetre) renvoie la largeur de la fenetre donc ça fonctionne. :wink:

aller un ptit bout fait a l'arrache non commenter :

Code : Tout sélectionner

;- Window Constants
Enumeration
	#Window_0
EndEnumeration

;- Gadget Constants
Enumeration
	#ProgressBar_0
EndEnumeration

	If OpenWindow(#Window_0, 0, 0, 170, 40, "",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
	  ProgressBarGadget(#ProgressBar_0, 10, 10, 150, 20, 0, 100)
	   SetGadgetState(#ProgressBar_0, 50)

	EndIf
	
	Repeat
		Event = WindowEvent()
		
		If Event = #PB_Event_MaximizeWindow
			Largeur = WindowWidth(#Window_0)
			ResizeGadget(#ProgressBar_0, 10, 10, Largeur-20, 20)
		EndIf
		
		If Event = #PB_Event_RestoreWindow
			Largeur = WindowWidth(#Window_0)
			ResizeGadget(#ProgressBar_0, 10, 10, 150, 20)
		EndIf
		
	Until Event = #PB_Event_CloseWindow






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
David02
Messages : 46
Inscription : mer. 30/mars/2011 9:50

Re: Problème redimensionner

Message par David02 »

Merci beaucoup :D
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: [Résolu] Problème redimensionner

Message par venom »

De rien,

tu te tromper c'est a partir de la ligne repeat regarde mien mon code et le tiens :wink:






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
David02
Messages : 46
Inscription : mer. 30/mars/2011 9:50

Re: [Résolu] Problème redimensionner

Message par David02 »

Ouais j'ai vu.

Mais toi tu as WindowEvent() mais je peux aussi mettre WaitWindowEvent à la place?
Car je crois avoir vu dans un topic qu'on ne pouvait pas mettre les 2, c'est l'un ou l'autre.
Avatar de l’utilisateur
venom
Messages : 3138
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: [Résolu] Problème redimensionner

Message par venom »

pour mieux comprendre affiche l'aide de purebasic et compare les 2 cas tu verra :wink:






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
David02
Messages : 46
Inscription : mer. 30/mars/2011 9:50

Re: [Résolu] Problème redimensionner

Message par David02 »

Voila j'ai effectuer le code sur un webgadget et cela fonctionne parfaitement.

J'ai mis WaitWindowEvent() car j'ai comparé les 2 dans l'aide et je préfère WaitWindowEvent :lol:

En tout cas merci pour l'aide :D
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: [Résolu] Problème redimensionner

Message par falsam »

En plus court ça doit aussi fonctionner (#PB_Event_SizeWindow)

Code : Tout sélectionner

;- Window Constants
Enumeration
   #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
   #ProgressBar_0
EndEnumeration

   If OpenWindow(#Window_0, 0, 0, 170, 40, "",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
     ProgressBarGadget(#ProgressBar_0, 10, 10, 150, 20, 0, 100)
     SetGadgetState(#ProgressBar_0, 50)
   EndIf
   
   Repeat
     Event = WaitWindowEvent()
     
     Select Event
      Case #PB_Event_SizeWindow
        Largeur = WindowWidth(#Window_0)
        ResizeGadget(#ProgressBar_0, #PB_Ignore, #PB_Ignore, Largeur-20, #PB_Ignore )
    EndSelect
         
   Until Event = #PB_Event_CloseWindow
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre