Utiliser ResizeWindows pour placer centrer un panel sans modifier sa taille

Programmation d'applications complexes
Avatar de l’utilisateur
Philippe_GEORGES
Messages : 138
Inscription : mer. 28/janv./2009 13:28

Utiliser ResizeWindows pour placer centrer un panel sans modifier sa taille

Message par Philippe_GEORGES »

Bonjour à tous,

Dans une fenêtre, j'ai placé un PanelGadget qui prends toute la place en usage normal (fenêtre non agrandie).

Je voudrais pouvoir centrer ce gadget dans la fenêtre, si cette fenêtre est agrandie, SANS MODIFIER SA TAILLE, simplement le centrer.

Mais comment faire ? ResizeGadget sais faire, mais il augmente la taille du Panel en le centrant.

Ca doit être simple, mais je ne trouve pas une solution fiable.

Merci d'avance,

Phil
Philippe GEORGES
"La simplicité est la sophistication suprême" (De Vinci)
assistance informatique, création de logiciels
georges.informatique@gmail.com
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Utiliser ResizeWindows pour placer centrer un panel sans modifier sa taille

Message par SPH »

Pourrais tu nous partager un petit code ? :idea:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
Mindphazer
Messages : 693
Inscription : mer. 24/août/2005 10:42

Re: Utiliser ResizeWindows pour placer centrer un panel sans modifier sa taille

Message par Mindphazer »

Hello Phil,
quelque chose comme ça ?

Code : Tout sélectionner

Enumeration 
  #MainWindow
  #Panel
EndEnumeration

Procedure OpenMainWindow(x = 0, y = 0, width = 430, height = 300)
  OpenWindow(#MainWindow, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  PanelGadget(#Panel, 10, 20, 410, 270)
  AddGadgetItem(#Panel, -1, "Tab 1")
  CloseGadgetList()
EndProcedure

Procedure ResizeGadgetsMainWindow()
  PanelX = WindowWidth(#MainWindow) / 2 - GadgetWidth(#Panel) / 2
  PanelY = WindowHeight(#MainWindow) / 2 - GadgetHeight(#Panel) / 2
  ResizeGadget(#Panel, PanelX, PanelY, #PB_Ignore, #PB_Ignore)
EndProcedure

OpenMainWindow()
BindEvent(#PB_Event_SizeWindow, @ResizeGadgetsMainWindow())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Bureau : Win10 64bits
Maison : Macbook Pro M3 16" SSD 512 Go / Ram 24 Go - iPad Pro 32 Go (pour madame) - iPhone 15 Pro Max 256 Go
Avatar de l’utilisateur
Philippe_GEORGES
Messages : 138
Inscription : mer. 28/janv./2009 13:28

Re: Utiliser ResizeWindows pour placer centrer un panel sans modifier sa taille

Message par Philippe_GEORGES »

Ben oui, incroyable !! Un grand merci !

Voici le code qui me fallait, je me dis que je n'avais pas assez réfléchi !!

Merci du temps passé pour me répondre !

Code : Tout sélectionner

Enumeration 
  #MainWindow
  #Panel
EndEnumeration

Declare ResizeGadgetsMainWindow()

Procedure OpenMainWindow(x = 0, y = 0, width = 430, height = 300)
  OpenWindow(#MainWindow, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget)
  PanelGadget(#Panel, 10, 20, 410, 270)
  AddGadgetItem(#Panel, -1, "Tab 1")
  CloseGadgetList()
  BindEvent(#PB_Event_SizeWindow, @ResizeGadgetsMainWindow())
EndProcedure

Procedure ResizeGadgetsMainWindow()
  PanelX = WindowWidth(#MainWindow) / 2 - GadgetWidth(#Panel) / 2
  PanelY = WindowHeight(#MainWindow) / 2 - GadgetHeight(#Panel) / 2
  ResizeGadget(#Panel, PanelX, PanelY, #PB_Ignore, #PB_Ignore)
EndProcedure

OpenMainWindow()

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Phil
Philippe GEORGES
"La simplicité est la sophistication suprême" (De Vinci)
assistance informatique, création de logiciels
georges.informatique@gmail.com
Répondre