For 1 year that I use Purebasic, I still did not understand how to manage the mouse in front of an "OpenWindowedScreen" screen included in an "OpenWindow" window. In the small program that I put below, I cannot click on the X which is at the top right to close the program or on _ to minimize the window.
I want to redefine the mouse cursor with a sprite that will be used in the "OpenWindowedScreen" window but I want to be able to click on the X of the "OpenWindow" window to close the game or on _ to minimize the window.
Thank you for your invaluable help.
Regards,
Jacques Joly
Code: Select all
;========== Gestion de la souris avec fenêtre "OpenWindow" et fenêtre "OpenWindowedScreen"
;= QUESTION :
;= Comment gérer la souris pour pouvoir cliquer sur le X de la fenêtre Windows afin de fermer la fenêtre ???????????
EnableExplicit
Global event.i
Global x_pave.w, y_pave.w
Global police.w
;=---------- Initialisation des environnements nécessaires
If InitSprite()=0 : MessageRequester("Erreur", "InitSprite() non initialisé !"):End:EndIf
If InitMouse()=0 : MessageRequester("Erreur", "InitMouse() non initialisé !"):End:EndIf
;=---------- Création de la fenêtre Windows
OpenWindow(0, 0, 0, 800,600, "Gestion souris avec fenêtre (OpenWindow) et fenêtre (OpenWindowedScreen) avec sprites", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget)
;=---------- Création de la fenêtre de jeu
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0)
;=---------- Création du sprite cercle
CreateSprite(0,50,50,#PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(0))
Circle(25, 25, 24, #Yellow)
StopDrawing()
;=---------- Création du sprite pavé
CreateSprite(1,15,15,#PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(1))
Box(0, 0, 15,15, #White)
StopDrawing()
;=---------- Chargement de la police
police=LoadFont(0, "Calibri", 24)
;=---------- Boucle
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
End
EndSelect
Until event = 0
ClearScreen(#Blue)
ExamineMouse()
x_pave=MouseX()
y_pave=MouseY()
DisplayTransparentSprite(0,100,100)
DisplayTransparentSprite(1,x_pave,y_pave)
;=---------- Vérifier si collision entre le curseur (pavé) et le cercle
If SpriteCollision(0,100,100,1,x_pave,y_pave)
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(police)
DrawText(100,300,"Collision",#Black)
StopDrawing()
EndIf
FlipBuffers()
ForEver