@Ar-S: En picorant dans le code que tu m'a donné, j'arrive a quelque chose qui fonctionne mais ne me satisfait pas complétement.
Ce fonctionnement a 2 fenêtres n'est pas très pro et comporte pas mal de défauts.
J'ai pensé que un skin serait peut-être la solution, mais là aussi, je n'ai aucune idée de comment m'y prendre.
Je vais creuser ça, il doit bien y avoir des exemples quelque part.
Code : Tout sélectionner
EnableExplicit
EnableDebugger
Enumeration Window
#winApp
#winTop
EndEnumeration
Enumeration Gadgets
#webView
#canvas
EndEnumeration
Enumeration Menus
#MenuTray
EndEnumeration
Enumeration SubMenus
#showApp
#quitter
EndEnumeration
Declare sizeWindow()
Declare moveWindow()
Declare setSysTray()
Declare showWindow()
#FLAGS1=#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_Invisible
#FLAGS2=#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget;|#PB_Window_SizeGadget
Define X,Y,W,H,win1,win2
Define Event,indexGadget,indexGadgetType,indexMenu
#WMIN=854:#HMIN=480:#HTOP=50
W=#WMIN
H=#HMIN
;
; CRÉATION FENÊTRE PRINCIPALE
;
win1=OpenWindow(#WinApp,0,0,W,H,"win1",#FLAGS1)
If win1
SetWindowColor(#WinApp,#White)
WebGadget(#webView,0,0,W,H,#Empty$,#PB_Web_Edge)
SetGadgetAttribute(#webView,#PB_Web_BlockPopups,#True)
SetGadgetAttribute(#webView,#PB_Web_BlockPopupMenu,#True)
SetGadgetText(#webView,"https://www.jango.com/")
SetWindowLong_(win1,#GWL_EXSTYLE,#WS_EX_TOOLWINDOW) ;Astuces pour empecher la fenetre d'apparaitre dans la barre des taches
EndIf
X=WindowX(#winApp)
Y=WindowY(#winApp)
;
; CRÉATION FENÊTRE SECONDAIRE
;
win2=OpenWindow(#winTop,X-3,Y,W,#HTOP,"win2",#FLAGS2)
If win1 And win2
;SetWindowLong_(win2,#GWL_EXSTYLE,#WS_EX_TOOLWINDOW)
HideWindow(#winApp,#False,#PB_Window_NoActivate|#PB_Window_ScreenCentered)
StickyWindow(#winTop,#True)
SetWindowColor(#winTop,#Yellow)
;CanvasGadget(#canvas,0,0,W,#HTOP,#PB_Canvas_Keyboard)
Else
End
EndIf
UsePNGImageDecoder()
setSysTray()
If CreatePopupImageMenu(#MenuTray, #PB_Menu_ModernLook)
MenuItem(#showApp,"App WebView")
MenuBar()
MenuItem(#quitter,"Quitter")
EndIf
SmartWindowRefresh(#winApp,#True)
SmartWindowRefresh(#wintop,#True)
BindEvent(#PB_Event_MoveWindow,@moveWindow())
BindEvent(#PB_Event_SizeWindow,@sizeWindow())
Define fullscreen=#False,N
Repeat
If GetAsyncKeyState_(#VK_ESCAPE)
HideWindow(#winApp,#True)
SetWindowState(#winTop, #PB_Window_Minimize)
EndIf
If GetAsyncKeyState_(#VK_Q)
Break
EndIf
Event = WaitWindowEvent(20)
Select Event
Case #PB_Event_Menu
indexMenu = EventMenu()
Select indexMenu
Case #showApp : showWindow()
Case #quitter : Break
EndSelect
Case #PB_Event_Gadget
indexGadget = EventGadget()
indexGadgetType = EventType()
Select indexGadget
;; Traitement des évenements des Gadgets
EndSelect
Case #PB_Event_MoveWindow
;Debug "MOVE"
Case #PB_Event_Repaint
;Debug "REPAINT"
Case #PB_Event_SizeWindow
;Debug "SIZE"
Case #PB_Event_MaximizeWindow
;Debug "MAXIMIZE"+fullscreen
If fullscreen=#False
SetWindowState(#winApp, #PB_Window_Maximize)
SetWindowState(#winTop, #PB_Window_Maximize)
ResizeWindow(#winTop,0,0,WindowWidth(#winApp),#HTOP)
ResizeGadget(#webView,0,0,WindowWidth(#winApp),WindowHeight(#winApp))
fullscreen=#True
Else
If N=0
N+1
Continue
Else
N=0
EndIf
SetWindowState(#winApp, #PB_Window_Normal)
ResizeWindow(#winTop,WindowX(#winApp),WindowY(#winApp),WindowWidth(#winApp),#HTOP)
fullscreen=#False
EndIf
Delay(500)
Case #PB_Event_MinimizeWindow
HideWindow(#winApp,#True)
HideWindow(#winTop,#True)
HideGadget(#webView,#True)
SetWindowState(#winTop, #PB_Window_Minimize)
;
Case #PB_Event_RestoreWindow
HideWindow(#winApp,#False)
X=WindowWidth(#winApp)
Y=WindowHeight(#winApp)
ResizeGadget(#webView,0,0,X,Y)
HideGadget(#webView,#False)
;
Case #PB_Event_ActivateWindow
;
Case #PB_Event_CloseWindow
Break
;
Case #PB_Event_SysTray
Select EventType()
Case #PB_EventType_RightClick
DisplayPopupMenu(#MenuTray, WindowID(#WinApp))
Case #PB_EventType_LeftClick
showWindow()
EndSelect
EndSelect
ForEver
End
Procedure moveWindow()
Debug "moveWin"
ResizeWindow(#winApp,WindowX(#winTop)+3,WindowY(#winTop),#PB_Ignore,#PB_Ignore)
EndProcedure
Procedure sizeWindow()
Debug "sizeWin"
ResizeWindow(#winTop,WindowX(#winApp)-3,WindowY(#winapp),WindowWidth(#winapp),#PB_Ignore)
ResizeGadget(#webView,0,0,WindowWidth(#winApp),WindowHeight(#winApp))
EndProcedure
Procedure setSysTray()
If FindWindow_("Progman",#NUL) <> 0
AddSysTrayIcon(#WinApp,WindowID(#WinApp),LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/world.png"))
SysTrayIconToolTip(#WinApp,"App WebView")
EndIf
EndProcedure
Procedure showWindow()
HideWindow(#WinApp, #False)
HideWindow(#WinTop, #False)
SetWindowState(#winTop, #PB_Window_Normal)
SetWindowState(#WinApp, #PB_Window_Normal)
StickyWindow(#winApp,#True)
StickyWindow(#winApp,#False)
StickyWindow(#winTop,#True)
SetActiveWindow(#winTop)
SetActiveWindow(#WinApp)
EndProcedure