Re: Redefinir les options d'une fenêtre
Publié : lun. 18/avr./2011 20:23
alors il faut peut-être masquer la fenêtre, la modifier et réafficher la fenêtre. Est-ce mieux ?
Code : Tout sélectionner
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
If OpenWindow(#Window_0, 0, 0, 600, 300, "Ma fenêtre", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
ButtonGadget(0, 5, 5, 290, 25, "Retirer la bordure")
ButtonGadget(1, 305, 5, 290, 25, "Remettre la bordure")
ButtonGadget(2, 5, 35, 290, 25, "Retirer le bouton minimiser")
ButtonGadget(3, 305, 35, 290, 25, "Remettre le bouton minimiser")
ButtonGadget(4, 5, 65, 290, 25, "Retirer le bouton maximiser")
ButtonGadget(5, 305, 65, 290, 25, "Remettre le bouton maximiser")
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
Select GadgetID
Case 0
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style & ~#WS_TILEDWINDOW)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
Case 1
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style | #WS_TILEDWINDOW)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
Case 2
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style & ~#WS_MINIMIZEBOX)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
Case 3
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style | #WS_MINIMIZEBOX)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
Case 4
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style & ~#WS_MAXIMIZEBOX)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
Case 5
HideWindow(#Window_0, 1)
; On récupère le style de la fenêtre
Style = GetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE)
; On modifie le style
SetWindowLongPtr_(WindowID(#Window_0), #GWL_STYLE, Style | #WS_MAXIMIZEBOX)
HideWindow(#Window_0, 0)
UpdateWindow_(WindowID(#Window_0))
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
EndIf