redimensionner un OpenwindowScreen

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

redimensionner un OpenwindowScreen

Message par Thyphoon »

Bonjour,

je viens partager une astuce que je viens de trouver pour redimensionner un OpenwindowScreen sans avoir a le fermer et a recharger tout vos spirites.
La question que je me pose c'est si ça marche sous windows est ce que ça fonctionne sous Linux et MacOsX ?
si vous avez une meilleur proposition je suis preneur ;o)

Code : Tout sélectionner

EnableExplicit

If InitSprite() = 0 Or InitSprite3D() =0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Error", "Can't open the sprite system", 0)
  End
EndIf

;-Gadget
Enumeration
  #WinMain
  
  #GdtScreen
EndEnumeration


ExamineDesktops()
If OpenWindow(#WinMain, 0, 0, DesktopWidth(0)-100, DesktopHeight(0)-100, "PureBasic Window", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
  ContainerGadget(#GdtScreen,200,0,800,600)
  OpenWindowedScreen(GadgetID(#GdtScreen),0,0,1920,1080) ;<=== l'astuce est là utilisé un GadgetID plutôt qu'un WindowID
EndIf

Procedure refreshWindow()
  ResizeGadget(#GdtScreen,#PB_Ignore,#PB_Ignore,WindowWidth(#WinMain)-GadgetX(#GdtScreen)-10,WindowHeight(#WinMain)-GadgetY(#GdtScreen)-10)
EndProcedure

Define Event.i
Repeat
    Repeat
      Event = WindowEvent()
      
      Select Event 
        
        Case #PB_Event_CloseWindow
          End
        Case #PB_Event_SizeWindow
          refreshWindow()
      EndSelect
    Until Event = 0
  
    FlipBuffers() 
    ClearScreen(RGB(0, 0, 0))
    
    Delay(1)
  ForEver

Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: redimensionner un OpenwindowScreen

Message par Backup »

Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: redimensionner un OpenwindowScreen

Message par Thyphoon »

Dobro a écrit :solution deja donné ici :
http://www.purebasic.fr/french/viewtopi ... n+GadgetID

:)
Harrrghh ! Merci Dobro j'avais pourtant cherché et je suis passé a côté :(
Par contre en utilisant le GadgetID j'ai un comportement curieux avec ExamineMouse() ....vous aviez déjà remarqué ça ?
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: redimensionner un OpenwindowScreen

Message par Thyphoon »

Voici un test que j'ai fait et qui montre qu'il y a un comportement currieux lorsqu'on utilise GadgetID
source du code d'origine : http://www.forums.purebasic.com/english ... 867e656036
Pour tester avec windowID ou GadgetID
il suffit de changer la constante #Test
#Test=0 ; utilisation de WindowID
#Test=1 ; utilisation de GadgetID

si quelqu'un a une idée de pourquoi ...

Code : Tout sélectionner

#Test=0

#LeftOffset = 20  
#TopOffset  = 20  
#ScreenW    = 440  
#ScreenH    = 440  

OpenWindow(0,0,0,800,500,"Screen Mouse Capture/Release Demo",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
If CreateMenu(0,WindowID(0))
  MenuTitle("Test")
  MenuItem(0,"Menu1")
  MenuItem(1,"Menu2")
EndIf
ButtonGadget(1,570,420,120,24,"Push Me!")  
InitSprite():InitMouse() 
;###################ICI POUR TESTER#################
If #Test=0
  OpenWindowedScreen(WindowID(0),20,20,440,440,0,0,0)
Else
  ContainerGadget(2,20,20,440,440)
  OpenWindowedScreen(GadgetID(2),0,0,440,440,0,0,0)  
EndIf

Procedure DoScreenDisplay(inscreen)  
  ClearScreen(0)  
  ;  
  ; Display your screen stuff  
  StartDrawing(ScreenOutput())  

  DrawText(120,200,"Screen is not capturing mouse ",#Gray, #Black)  
  DrawText(180,230,"( 000, 000 )", #Gray, #Black)     
  StopDrawing()   
  ;  
  If inscreen  ; manage mouse events only if mouse is inside screen  
    WindowEvent() 
    ExamineMouse()  
    StartDrawing(ScreenOutput())  
    DrawText(120,200," Screen is capturing mouse ",#Yellow, #Black)  
    DrawText(180,230,"( "+RSet(Str(MouseX()),3,"0")+", "+RSet(Str(MouseY()),3,"0")+" )",#White,#Black)  
    
    If MouseButton(#PB_MouseButton_Left)  
      FillArea(186,316,0,#Red)  
    EndIf  
    
    If MouseButton(#PB_MouseButton_Middle)  
      FillArea(202,311,0,#Red)  
    EndIf  
    If MouseButton(#PB_MouseButton_Right)  
      FillArea(216,306,0,#Red)  
    EndIf  
    
    Circle(MouseX(),MouseY(),5,#Red)  
    StopDrawing()  
    
  EndIf  
  FlipBuffers()  
EndProcedure  

Repeat  
  ev = WaitWindowEvent()  
  If inscreen  
    If MouseX()>#ScreenW-2 Or MouseY()>#ScreenH-2 Or MouseX()<1 Or MouseY()<1  
      ReleaseMouse(1)  
      inscreen = #False  
    EndIf   
  Else  
    ;  
    ;************************************  
    ; Handle #PB_Event_Gadget Here  
    ;************************************  
    ;  
    If ev = #PB_Event_Gadget  
      If EventGadget() = 1  
        MessageRequester("","You pressed the button!")  
      EndIf  
    EndIf
    
    If ev = #PB_Event_Menu
      Select EventMenu()
        Case 0 : Debug "Menu1"
        Case 1 : Debug "Menu2"
      EndSelect
    EndIf
    ; 
    mx = WindowMouseX(0):my = WindowMouseY(0)  
    If mx < #ScreenW+#LeftOffset And mx > #LeftOffset And my > #TopOffset And my < #TopOffset+#ScreenH  
      ReleaseMouse(0)  
      MouseLocate(mx-#LeftOffset,my-#TopOffset)  
      inscreen = #True  
    EndIf  
  EndIf  
  DoScreenDisplay(inscreen)  
Until ev = #PB_Event_CloseWindow  

DataSection  
  PicPak:  
  Data.b $4A,$43,$48,$1B,$00,$00,$16,$6A,$D7,$16,$B4,$A9,$D0,$20,$6D,$14,$D9,$88,$12,$CA  
  Data.b $08,$B0,$4A,$44,$25,$B2,$0C,$10,$46,$02,$11,$D2,$28,$79,$12,$02,$5B,$28,$09,$80  
  Data.b $29,$02,$E2,$1F,$01,$FF,$09,$BE,$74,$5F,$A5,$E0,$52,$77,$95,$DC,$4A,$A6,$51,$F2  
  Data.b $28,$09,$FE,$83,$84,$14,$68,$7F,$84,$00,$47,$A0,$FA,$11,$22,$1F,$81,$D8,$11,$C8  
  Data.b $7A,$04,$6E,$47,$A0,$E3,$04,$12,$1D,$81,$C0,$11,$48,$71,$81,$C0,$46,$20,$66,$04  
  Data.b $2A,$1A,$A0,$91,$11,$48,$18,$81,$2C,$46,$00,$30,$02,$6A,$0F,$68,$60,$84,$51,$80  
  Data.b $7D,$DC,$57,$80,$F9,$82,$08,$69,$EC,$C8,$46,$0E,$20,$C2,$EC,$5D,$CC,$E3,$68,$1F  
  Data.b $99,$45,$16,$2F,$66,$E4,$20,$A9,$68,$00,$BC,$58,$00,$0E,$A0,$37,$9A,$61,$47,$EE  
  Data.b $C8,$4C,$2D,$0A,$43,$A3,$56,$D1,$03,$6C,$77,$6C,$DC,$67,$3E,$CC,$32,$FA,$23,$46  
  Data.b $0B,$30,$91,$AA,$C8,$AC,$80,$59,$BC,$C8,$68,$9B,$99,$75,$91,$3E,$32,$1B,$AE,$83  
  Data.b $C2,$D8,$A2,$64,$22,$45,$2F,$06,$00,$31,$F3,$6C,$24,$12,$8E,$19,$B9,$6D,$C6,$CC  
  Data.b $17,$B6,$32,$D4,$29,$EE,$10,$25,$62,$5C,$30,$2C,$80,$86,$79,$28,$39,$94,$5C,$24  
  Data.b $25,$30,$52,$9A,$14,$69,$B3,$32,$A1,$32,$8A,$CD,$2E,$32,$18,$14,$15,$33,$46,$A8  
  Data.b $78,$78,$E8,$B8,$31,$23,$58,$1F,$18,$03,$0D,$19,$3A,$8C,$7E,$3C,$33,$88,$11,$8B  
  Data.b $CC,$3A,$01,$80,$50,$47,$0C,$AA,$D8,$3A,$48,$9C,$60,$44,$E8,$E0,$3E,$9D,$02,$6C  
  Data.b $12,$09,$D3,$23,$C1,$01,$25,$91,$36,$29,$4C,$F3,$12,$28,$5F,$14,$B1,$C8,$52,$27  
  Data.b $14,$27,$44,$9A,$41,$49,$03,$6A,$F3,$F4,$36,$2B,$C0,$5A,$0B,$34,$33,$C5,$A6,$35  
  Data.b $5B,$26,$69,$46,$93,$19,$41,$B1,$53,$FC,$12,$31,$2E,$6B,$5A,$05,$98,$25,$61,$82  
  Data.b $B7,$49,$A1,$2A,$23,$11,$BA,$C6,$CC,$83,$B4,$D8,$29,$4D,$A8,$49,$90,$70,$F3,$12  
  Data.b $33,$2A,$86,$A2,$34,$67,$CC,$68,$9C,$E4,$98,$59,$66,$93,$79,$D9,$C9,$D5,$A4,$44  
  Data.b $E9,$64,$60,$95,$CB,$A6,$C0,$20,$C9,$1D,$5E,$52,$60,$52,$3C,$8F,$CC,$30,$E7,$B7  
  Data.b $E8,$75,$D9,$69,$AC,$0B,$03,$CC,$22,$B9,$EA,$92,$12,$E8,$94,$D4,$04,$5B,$73,$FE  
  Data.b $63,$E6,$3B,$35,$C9,$61,$25,$12,$D3,$A2,$3E,$FA,$07,$58,$00,$86,$92,$54,$B0,$2C  
  Data.b $4F,$64,$B0,$39,$4F,$BA,$49,$C0,$26,$B1,$02,$8C,$82,$59,$47,$BA,$2C,$AF,$32,$DB  
  Data.b $A4,$8C,$B3,$2A,$D6,$62,$4D,$C7,$20,$63,$B7,$FC,$A2,$47,$94,$44,$D9,$00,$84,$32  
  Data.b $32,$D3,$92,$C7,$CC,$FB,$C7,$4B,$4C,$29,$12,$B3,$AC,$23,$44,$66,$97,$13,$54,$D6  
  Data.b $C4,$54,$C8,$CD,$71,$C3,$0B,$B0,$0A,$63,$2A,$29,$1D,$AD,$2B,$36,$67,$F2,$2B,$B1  
  Data.b $C2,$F4,$2E,$93,$41,$D2,$32,$B3,$34,$4A,$AA,$73,$D2,$BB,$76,$8A,$FB,$81,$23,$C7  
  Data.b $C7,$4C,$2E,$99,$90,$D0,$68,$5F,$80,$55,$CD,$E2,$95,$F9,$9D,$68,$A5,$69,$30,$86  
  Data.b $DD,$1C,$09,$80,$6B,$C2,$13,$2A,$32,$28,$68,$6D,$2B,$BF,$CE,$A8,$D8,$A5,$3D,$66  
  Data.b $17,$4C,$C5,$49,$B2,$51,$53,$26,$DF,$09,$4A,$1A,$AD,$45,$01,$56,$B9,$6C,$D1,$27  
  Data.b $26,$D7,$78,$61,$6E,$7A,$2B,$76,$61,$47,$99,$55,$28,$37,$55,$B1,$F1,$15,$49,$49  
  Data.b $17,$1C,$C8,$AC,$22,$99,$CC,$4B,$93,$AF,$4A,$2F,$38,$DF,$CC,$2C,$17,$CD,$30,$3B  
  Data.b $ED,$8A,$BB,$F0,$31,$E9,$3D,$66,$99,$16,$99,$34,$99,$F9,$51,$FA,$3A,$74,$60,$5E  
  Data.b $DA,$E9,$D1,$EF,$31,$BB,$BF,$7F,$6F,$F3,$32,$15,$03,$10,$8B,$8D,$84,$D6,$46,$F9  
  Data.b $2D,$66,$CF,$4E,$19,$82,$83,$B6,$4C,$45,$58,$3F,$66,$8C,$D8,$9C,$22,$01,$B8,$58  
  Data.b $00,$7E,$1E,$52,$94,$85,$FB,$31,$C3,$38,$B2,$BC,$15,$8A,$0C,$85,$B2,$7A,$0C,$21  
  Data.b $71,$A7,$5A,$D7,$B1,$55,$E1,$85,$42,$2D,$0A,$1B,$2F,$94,$24,$F4,$7E,$CC,$65,$6D  
  Data.b $2C,$7A,$3B,$55,$48,$07,$EF,$C7,$0C,$83,$F5,$38,$47,$43,$02,$AD,$E6,$A8,$CC,$12  
  Data.b $59,$A4,$A3,$91,$F2,$5E,$68,$25,$F1,$31,$26,$86,$A0,$ED,$CA,$9D,$C2,$0C,$3F,$AE  
  Data.b $22,$A8,$C3,$7B,$A4,$E8,$2E,$82,$B2,$14,$D3,$8A,$BE,$5C,$38,$0E,$8E,$FA,$E2,$90  
  Data.b $CA,$B5,$20,$17,$07,$D7,$CC,$AC,$AA,$D8,$A4,$E6,$29,$6F,$3B,$18,$3C,$4C,$31,$2B  
  Data.b $4C,$82,$8F,$51,$D0,$FE,$31,$D1,$6A,$92,$08,$B4,$7C,$0F,$06,$27,$9D,$20,$E4,$FC  
  Data.b $CB,$D8,$3B,$A4,$12,$0D,$07,$2E,$92,$40,$85,$39,$EB,$B0,$7D,$8D,$19,$61,$B0,$4D  
  Data.b $15,$22,$9F,$C0,$DE,$1A,$EA,$42,$68,$26,$AA,$D0,$FF,$47,$33,$45,$BF,$C6,$48,$69  
  Data.b $08,$09,$94,$30,$94,$85,$A3,$A1,$FD,$2D,$5C,$FE,$BE,$D5,$9A,$80,$A0,$B0,$1C,$5A  
  Data.b $96,$25,$A3,$DF,$85,$EA,$0D,$32,$F8,$31,$7F,$4F,$D1,$84,$D0,$39,$0E,$69,$AB,$C7  
  Data.b $2C,$90,$77,$AF,$47,$44,$BF,$42,$45,$3A,$B8,$30,$AB,$1F,$0C,$B4,$EF,$CC,$BD,$66  
  Data.b $E8,$5A,$F4,$BB,$A0,$16,$40,$43,$3B,$38,$F5,$CD,$54,$92,$FB,$9E,$07,$18,$88,$84  
  Data.b $81,$D4,$C5,$66,$47,$6E,$57,$8D,$85,$DE,$C0,$14,$5F,$05,$53,$DC,$6C,$F6,$7E,$90  
  Data.b $D4,$B9,$0F,$59,$7E,$67,$C0,$93,$04,$5A,$CC,$C4,$E4,$A8,$31,$43,$B4,$CA,$47,$8A  
  Data.b $12,$BB,$59,$97,$55,$E8,$B9,$86,$3F,$5E,$83,$54,$D9,$71,$77,$38,$57,$8C,$DA,$14  
  Data.b $20,$A2,$6B,$85,$81,$5C,$FB,$04,$0F,$FD,$C7,$43,$FB,$66,$91,$9F,$81,$2E,$02,$6D  
  Data.b $18,$0A,$D6,$35,$A3,$E4,$A4,$19,$6A,$D0,$40,$6A,$2A,$4C,$CA,$9A,$AE,$C4,$66,$0B  
  Data.b $44,$F4,$10,$51,$31,$AC,$04,$3B,$1E,$6A,$91,$AE,$9D,$F2,$F9,$02,$E0,$AB,$45,$20  
  Data.b $08,$15,$62,$0D,$AA,$0B,$4D,$91,$6E,$8E,$B9,$D8,$AC,$E8,$2E,$13,$BF,$22,$45,$16  
  Data.b $CD,$D1,$EF,$10,$41,$AA,$4F,$82,$62,$61,$F0,$90,$69,$90,$45,$FA,$CD,$4E,$1C,$AD  
  Data.b $12,$B3,$29,$CA,$44,$AE,$D0,$4F,$9B,$F2,$94,$B2,$16,$2E,$15,$51,$20,$A4,$68,$65  
  Data.b $51,$83,$A2,$57,$62,$A6,$54,$BC,$60,$5D,$F5,$70,$51,$89,$8E,$B5,$C4,$71,$64,$80  
  Data.b $00,$3C,$52,$A4,$E8,$A2,$13,$AE,$1E,$F9,$2A,$57,$F9,$22,$E0,$12,$A9,$18,$B7,$20  
  Data.b $D0,$6F,$0E,$19,$C2,$04,$36,$43,$73,$B4,$44,$AE,$EC,$2A,$1C,$17,$19,$43,$8E,$F2  
  Data.b $5D,$A8,$0B,$B3,$40,$7A,$0D,$00,$88,$84,$AA,$00,$E3,$9A,$16,$E3,$72,$D3,$1F,$E9  
  Data.b $58,$A8,$A3,$42,$B8,$18,$12,$D2,$8B,$C9,$F8,$7A,$A5,$CE,$E5,$2E,$4D,$A4,$A4,$C4  
  Data.b $A4,$0E,$81,$CE,$22,$71,$72,$D2,$91,$4E,$EA,$8E,$0D,$F3,$2E,$93,$42,$3B,$8B,$E4  
  Data.b $B7,$F2,$CA,$48,$AE,$61,$CE,$93,$BB,$CC,$DB,$BC,$C4,$E4,$01,$2C,$7B,$12,$C3,$A4  
  Data.b $84,$F4,$12,$FE,$4C,$E8,$46,$57,$A2,$77,$59,$09,$69,$67,$75,$01,$F6,$89,$5A,$47  
  Data.b $9F,$E5,$51,$52,$24,$00,$DE,$D9,$5D,$98,$B3,$68,$52,$F4,$48,$C4,$EA,$00,$00,$00  
  Data.b $00,$80  
EndDataSection
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: redimensionner un OpenwindowScreen

Message par Backup »

deja evite d'utiliser plusieurs windowevent() ,....

je pense que comme tu asservi l'ecran a un gadget , c'ets plus l'ecran qui est prioritaire, c'est le gadget !
donc il faut surveiller si la souris survole le gadget ....

cette exemple ne marche qu'avec #test=1

j'ai eu la bulle de le rendre compatible 2 version

Code : Tout sélectionner

#Test=1 ; marche seulement avec #test=1... 

#LeftOffset = 20 
#TopOffset  = 20 
#ScreenW    = 440 
#ScreenH    = 440 
Macro GadgetHoverCheck(x, Y, gadget)
	(((Not x<GadgetX(gadget)) & (Not Y<GadgetY(gadget))) & (Not x>=(GadgetX(gadget)+GadgetWidth(gadget))) & (Not Y>=(GadgetY(gadget)+GadgetHeight(gadget))))
EndMacro


OpenWindow(0,0,0,800,500,"Screen Mouse Capture/Release Demo",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
If CreateMenu(0,WindowID(0))
	MenuTitle("Test")
	MenuItem(0,"Menu1")
	MenuItem(1,"Menu2")
EndIf
ButtonGadget(1,570,420,120,24,"Push Me!") 
InitSprite():InitMouse()
;###################ICI POUR TESTER#################
If #Test=0
	OpenWindowedScreen(WindowID(0),20,20,440,440,0,0,0)
	Else
	ContainerGadget(2,20,20,440,440)
	OpenWindowedScreen(GadgetID(2),0,0,440,440,0,0,0) 
EndIf

Procedure DoScreenDisplay(inscreen) 
	ClearScreen(0) 
	; 
	; Display your screen stuff 
	StartDrawing(ScreenOutput()) 
		
		DrawText(120,200,"Screen is not capturing mouse ",#Gray, #Black) 
		DrawText(180,230,"( 000, 000 )", #Gray, #Black)     
	StopDrawing()   
	; 
	If inscreen  ; manage mouse events only if mouse is inside screen 
		
		ExamineMouse() 
		StartDrawing(ScreenOutput()) 
			DrawText(120,200," Screen is capturing mouse ",#Yellow, #Black) 
			DrawText(180,230,"( "+RSet(Str(MouseX()),3,"0")+", "+RSet(Str(MouseY()),3,"0")+" )",#White,#Black) 
			
			If MouseButton(#PB_MouseButton_Left) 
				FillArea(186,316,0,#Red) 
			EndIf 
			
			If MouseButton(#PB_MouseButton_Middle) 
				FillArea(202,311,0,#Red) 
			EndIf 
			If MouseButton(#PB_MouseButton_Right) 
				FillArea(216,306,0,#Red) 
			EndIf 
			
			Circle(MouseX(),MouseY(),5,#Red) 
		StopDrawing() 
		
	EndIf 
	FlipBuffers() 
EndProcedure 

Repeat 
	ev = WaitWindowEvent(2) 
	
	If inscreen 
		If MouseX()>#ScreenW-2 Or MouseY()>#ScreenH-2 Or MouseX()<1 Or MouseY()<1  or (#test<>0 and bool(GadgetHoverCheck(WindowMouseX(0), WindowMouseY(0), 2))=1)
			ReleaseMouse(1) 
			inscreen = #False 
		EndIf   
		Else 
		; 
		;************************************ 
		; Handle #PB_Event_Gadget Here 
		;************************************ 
		; 
		If ev = #PB_Event_Gadget 
			If EventGadget() = 1 
				MessageRequester("","You pressed the button!") 
			EndIf 
		EndIf
		
		If ev = #PB_Event_Menu
			Select EventMenu()
				Case 0 : Debug "Menu1"
				Case 1 : Debug "Menu2"
			EndSelect
		EndIf
		;
		mx = WindowMouseX(0):my = WindowMouseY(0) 
		If mx < #ScreenW+#LeftOffset And mx > #LeftOffset And my > #TopOffset And my < #TopOffset+#ScreenH and ( #test<>0 or bool(GadgetHoverCheck(WindowMouseX(0), WindowMouseY(0), 2))=0)
			ReleaseMouse(0) 
			MouseLocate(mx-#LeftOffset,my-#TopOffset) 
			inscreen = #True 
		EndIf 
	EndIf 
	DoScreenDisplay(inscreen) 
Until ev = #PB_Event_CloseWindow 

DataSection 
	PicPak: 
	Data.b $4A,$43,$48,$1B,$00,$00,$16,$6A,$D7,$16,$B4,$A9,$D0,$20,$6D,$14,$D9,$88,$12,$CA 
	Data.b $08,$B0,$4A,$44,$25,$B2,$0C,$10,$46,$02,$11,$D2,$28,$79,$12,$02,$5B,$28,$09,$80 
	Data.b $29,$02,$E2,$1F,$01,$FF,$09,$BE,$74,$5F,$A5,$E0,$52,$77,$95,$DC,$4A,$A6,$51,$F2 
	Data.b $28,$09,$FE,$83,$84,$14,$68,$7F,$84,$00,$47,$A0,$FA,$11,$22,$1F,$81,$D8,$11,$C8 
	Data.b $7A,$04,$6E,$47,$A0,$E3,$04,$12,$1D,$81,$C0,$11,$48,$71,$81,$C0,$46,$20,$66,$04 
	Data.b $2A,$1A,$A0,$91,$11,$48,$18,$81,$2C,$46,$00,$30,$02,$6A,$0F,$68,$60,$84,$51,$80 
	Data.b $7D,$DC,$57,$80,$F9,$82,$08,$69,$EC,$C8,$46,$0E,$20,$C2,$EC,$5D,$CC,$E3,$68,$1F 
	Data.b $99,$45,$16,$2F,$66,$E4,$20,$A9,$68,$00,$BC,$58,$00,$0E,$A0,$37,$9A,$61,$47,$EE 
	Data.b $C8,$4C,$2D,$0A,$43,$A3,$56,$D1,$03,$6C,$77,$6C,$DC,$67,$3E,$CC,$32,$FA,$23,$46 
	Data.b $0B,$30,$91,$AA,$C8,$AC,$80,$59,$BC,$C8,$68,$9B,$99,$75,$91,$3E,$32,$1B,$AE,$83 
	Data.b $C2,$D8,$A2,$64,$22,$45,$2F,$06,$00,$31,$F3,$6C,$24,$12,$8E,$19,$B9,$6D,$C6,$CC 
	Data.b $17,$B6,$32,$D4,$29,$EE,$10,$25,$62,$5C,$30,$2C,$80,$86,$79,$28,$39,$94,$5C,$24 
	Data.b $25,$30,$52,$9A,$14,$69,$B3,$32,$A1,$32,$8A,$CD,$2E,$32,$18,$14,$15,$33,$46,$A8 
	Data.b $78,$78,$E8,$B8,$31,$23,$58,$1F,$18,$03,$0D,$19,$3A,$8C,$7E,$3C,$33,$88,$11,$8B 
	Data.b $CC,$3A,$01,$80,$50,$47,$0C,$AA,$D8,$3A,$48,$9C,$60,$44,$E8,$E0,$3E,$9D,$02,$6C 
	Data.b $12,$09,$D3,$23,$C1,$01,$25,$91,$36,$29,$4C,$F3,$12,$28,$5F,$14,$B1,$C8,$52,$27 
	Data.b $14,$27,$44,$9A,$41,$49,$03,$6A,$F3,$F4,$36,$2B,$C0,$5A,$0B,$34,$33,$C5,$A6,$35 
	Data.b $5B,$26,$69,$46,$93,$19,$41,$B1,$53,$FC,$12,$31,$2E,$6B,$5A,$05,$98,$25,$61,$82 
	Data.b $B7,$49,$A1,$2A,$23,$11,$BA,$C6,$CC,$83,$B4,$D8,$29,$4D,$A8,$49,$90,$70,$F3,$12 
	Data.b $33,$2A,$86,$A2,$34,$67,$CC,$68,$9C,$E4,$98,$59,$66,$93,$79,$D9,$C9,$D5,$A4,$44 
	Data.b $E9,$64,$60,$95,$CB,$A6,$C0,$20,$C9,$1D,$5E,$52,$60,$52,$3C,$8F,$CC,$30,$E7,$B7 
	Data.b $E8,$75,$D9,$69,$AC,$0B,$03,$CC,$22,$B9,$EA,$92,$12,$E8,$94,$D4,$04,$5B,$73,$FE 
	Data.b $63,$E6,$3B,$35,$C9,$61,$25,$12,$D3,$A2,$3E,$FA,$07,$58,$00,$86,$92,$54,$B0,$2C 
	Data.b $4F,$64,$B0,$39,$4F,$BA,$49,$C0,$26,$B1,$02,$8C,$82,$59,$47,$BA,$2C,$AF,$32,$DB 
	Data.b $A4,$8C,$B3,$2A,$D6,$62,$4D,$C7,$20,$63,$B7,$FC,$A2,$47,$94,$44,$D9,$00,$84,$32 
	Data.b $32,$D3,$92,$C7,$CC,$FB,$C7,$4B,$4C,$29,$12,$B3,$AC,$23,$44,$66,$97,$13,$54,$D6 
	Data.b $C4,$54,$C8,$CD,$71,$C3,$0B,$B0,$0A,$63,$2A,$29,$1D,$AD,$2B,$36,$67,$F2,$2B,$B1 
	Data.b $C2,$F4,$2E,$93,$41,$D2,$32,$B3,$34,$4A,$AA,$73,$D2,$BB,$76,$8A,$FB,$81,$23,$C7 
	Data.b $C7,$4C,$2E,$99,$90,$D0,$68,$5F,$80,$55,$CD,$E2,$95,$F9,$9D,$68,$A5,$69,$30,$86 
	Data.b $DD,$1C,$09,$80,$6B,$C2,$13,$2A,$32,$28,$68,$6D,$2B,$BF,$CE,$A8,$D8,$A5,$3D,$66 
	Data.b $17,$4C,$C5,$49,$B2,$51,$53,$26,$DF,$09,$4A,$1A,$AD,$45,$01,$56,$B9,$6C,$D1,$27 
	Data.b $26,$D7,$78,$61,$6E,$7A,$2B,$76,$61,$47,$99,$55,$28,$37,$55,$B1,$F1,$15,$49,$49 
	Data.b $17,$1C,$C8,$AC,$22,$99,$CC,$4B,$93,$AF,$4A,$2F,$38,$DF,$CC,$2C,$17,$CD,$30,$3B 
	Data.b $ED,$8A,$BB,$F0,$31,$E9,$3D,$66,$99,$16,$99,$34,$99,$F9,$51,$FA,$3A,$74,$60,$5E 
	Data.b $DA,$E9,$D1,$EF,$31,$BB,$BF,$7F,$6F,$F3,$32,$15,$03,$10,$8B,$8D,$84,$D6,$46,$F9 
	Data.b $2D,$66,$CF,$4E,$19,$82,$83,$B6,$4C,$45,$58,$3F,$66,$8C,$D8,$9C,$22,$01,$B8,$58 
	Data.b $00,$7E,$1E,$52,$94,$85,$FB,$31,$C3,$38,$B2,$BC,$15,$8A,$0C,$85,$B2,$7A,$0C,$21 
	Data.b $71,$A7,$5A,$D7,$B1,$55,$E1,$85,$42,$2D,$0A,$1B,$2F,$94,$24,$F4,$7E,$CC,$65,$6D 
	Data.b $2C,$7A,$3B,$55,$48,$07,$EF,$C7,$0C,$83,$F5,$38,$47,$43,$02,$AD,$E6,$A8,$CC,$12 
	Data.b $59,$A4,$A3,$91,$F2,$5E,$68,$25,$F1,$31,$26,$86,$A0,$ED,$CA,$9D,$C2,$0C,$3F,$AE 
	Data.b $22,$A8,$C3,$7B,$A4,$E8,$2E,$82,$B2,$14,$D3,$8A,$BE,$5C,$38,$0E,$8E,$FA,$E2,$90 
	Data.b $CA,$B5,$20,$17,$07,$D7,$CC,$AC,$AA,$D8,$A4,$E6,$29,$6F,$3B,$18,$3C,$4C,$31,$2B 
	Data.b $4C,$82,$8F,$51,$D0,$FE,$31,$D1,$6A,$92,$08,$B4,$7C,$0F,$06,$27,$9D,$20,$E4,$FC 
	Data.b $CB,$D8,$3B,$A4,$12,$0D,$07,$2E,$92,$40,$85,$39,$EB,$B0,$7D,$8D,$19,$61,$B0,$4D 
	Data.b $15,$22,$9F,$C0,$DE,$1A,$EA,$42,$68,$26,$AA,$D0,$FF,$47,$33,$45,$BF,$C6,$48,$69 
	Data.b $08,$09,$94,$30,$94,$85,$A3,$A1,$FD,$2D,$5C,$FE,$BE,$D5,$9A,$80,$A0,$B0,$1C,$5A 
	Data.b $96,$25,$A3,$DF,$85,$EA,$0D,$32,$F8,$31,$7F,$4F,$D1,$84,$D0,$39,$0E,$69,$AB,$C7 
	Data.b $2C,$90,$77,$AF,$47,$44,$BF,$42,$45,$3A,$B8,$30,$AB,$1F,$0C,$B4,$EF,$CC,$BD,$66 
	Data.b $E8,$5A,$F4,$BB,$A0,$16,$40,$43,$3B,$38,$F5,$CD,$54,$92,$FB,$9E,$07,$18,$88,$84 
	Data.b $81,$D4,$C5,$66,$47,$6E,$57,$8D,$85,$DE,$C0,$14,$5F,$05,$53,$DC,$6C,$F6,$7E,$90 
	Data.b $D4,$B9,$0F,$59,$7E,$67,$C0,$93,$04,$5A,$CC,$C4,$E4,$A8,$31,$43,$B4,$CA,$47,$8A 
	Data.b $12,$BB,$59,$97,$55,$E8,$B9,$86,$3F,$5E,$83,$54,$D9,$71,$77,$38,$57,$8C,$DA,$14 
	Data.b $20,$A2,$6B,$85,$81,$5C,$FB,$04,$0F,$FD,$C7,$43,$FB,$66,$91,$9F,$81,$2E,$02,$6D 
	Data.b $18,$0A,$D6,$35,$A3,$E4,$A4,$19,$6A,$D0,$40,$6A,$2A,$4C,$CA,$9A,$AE,$C4,$66,$0B 
	Data.b $44,$F4,$10,$51,$31,$AC,$04,$3B,$1E,$6A,$91,$AE,$9D,$F2,$F9,$02,$E0,$AB,$45,$20 
	Data.b $08,$15,$62,$0D,$AA,$0B,$4D,$91,$6E,$8E,$B9,$D8,$AC,$E8,$2E,$13,$BF,$22,$45,$16 
	Data.b $CD,$D1,$EF,$10,$41,$AA,$4F,$82,$62,$61,$F0,$90,$69,$90,$45,$FA,$CD,$4E,$1C,$AD 
	Data.b $12,$B3,$29,$CA,$44,$AE,$D0,$4F,$9B,$F2,$94,$B2,$16,$2E,$15,$51,$20,$A4,$68,$65 
	Data.b $51,$83,$A2,$57,$62,$A6,$54,$BC,$60,$5D,$F5,$70,$51,$89,$8E,$B5,$C4,$71,$64,$80 
	Data.b $00,$3C,$52,$A4,$E8,$A2,$13,$AE,$1E,$F9,$2A,$57,$F9,$22,$E0,$12,$A9,$18,$B7,$20 
	Data.b $D0,$6F,$0E,$19,$C2,$04,$36,$43,$73,$B4,$44,$AE,$EC,$2A,$1C,$17,$19,$43,$8E,$F2 
	Data.b $5D,$A8,$0B,$B3,$40,$7A,$0D,$00,$88,$84,$AA,$00,$E3,$9A,$16,$E3,$72,$D3,$1F,$E9 
	Data.b $58,$A8,$A3,$42,$B8,$18,$12,$D2,$8B,$C9,$F8,$7A,$A5,$CE,$E5,$2E,$4D,$A4,$A4,$C4 
	Data.b $A4,$0E,$81,$CE,$22,$71,$72,$D2,$91,$4E,$EA,$8E,$0D,$F3,$2E,$93,$42,$3B,$8B,$E4 
	Data.b $B7,$F2,$CA,$48,$AE,$61,$CE,$93,$BB,$CC,$DB,$BC,$C4,$E4,$01,$2C,$7B,$12,$C3,$A4 
	Data.b $84,$F4,$12,$FE,$4C,$E8,$46,$57,$A2,$77,$59,$09,$69,$67,$75,$01,$F6,$89,$5A,$47 
	Data.b $9F,$E5,$51,$52,$24,$00,$DE,$D9,$5D,$98,$B3,$68,$52,$F4,$48,$C4,$EA,$00,$00,$00 
	Data.b $00,$80 
EndDataSection
; EPB
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: redimensionner un OpenwindowScreen

Message par Thyphoon »

Merci beaucoup Dobro ! tu m’épatera toujours !
En vérité là je m'inspire d'un code de netmaestro sur le forum anglais (ici)
ou je souhaite redimensionner facilement le screen !

Merci pour ta modification, mais il reste un petit bug, cars la souris n'est jamais capturé par le screen, et la variable inscreen clignote elle passe sont temps a dire qu'elle est dans l'ecran et a l'exterrieur lorsque la souris est positionné sur le screen ... Je cherche pourquoi ... (je dois être un peu rouillé en PB :P )
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: redimensionner un OpenwindowScreen

Message par Backup »

bon voici la soluce :)
elle passe par l'utilisation d'un callBack :)
et on n'utilise meme pas le Releasemouse :)
pour info ReleaseMouse() ne sert que dans le cas ou on reduit dans la barre des taches l'ecran pour faire autre chose sur windows ou un autre prg
ça sert surtout en mode SCREEN() , le mode WindowedScreen lui etant en fenetre , yen a pas besoin ;)

ce code permet d'afficher un sprite au coordonées de la souris lorsqu'elle est dans l'ecran
il permet le redimensionnement de l'ecran ( celui-ci a une dimension maximal de 1024x768 .. voir dans le code )
il permet l'utilisation de gadget en dehors de l'ecran , ici un bouton pour montrer le principe
il affiche en permanence les coordonées de la souris ....

il devrai meme etre multiplateforme ... :)

j'ai mis en commentaire les lignes
";showcursor_(0) ; /// ;showcursor_(1) ; " qui font appel a l'api windows pour cacher/montrer le curseur de souris windows ( la fleche )
il doit y avoir équivalant sur les autres OS :)


le code :

Code : Tout sélectionner


; Exemple de redimention du Screen 
; et de la capture Souris
; Par Dobro
; en Purebasic 5.11

Enumeration
	#win
	#container
	#sprite_curseur
	#bouton
EndEnumeration
Declare  open_win()
Declare  MyWindowCallback(WindowID, Message, wParam, lParam)


If InitSprite()=0 Or InitKeyboard()=0 or InitMouse()=0
	MessageRequester("Erreur", "DirectX 7 ou ultérieur indisponible !", 0)
	End
EndIf

open_win()

CreateSprite(#sprite_curseur,16,16)
StartDrawing(SpriteOutput(#sprite_curseur))
	Box(0,0,16,16,$0000FF)
StopDrawing() 

Repeat
	ExamineKeyboard()
	ExamineMouse()
	
	if WindowMouseX(#win)<WindowWidth(#Win)-70 and WindowMouseY(#win)<WindowHeight(#Win)-72 ; on est dans l'ecran ??? 
		;showcursor_(0) ; Dans l'ecran on affiche le Sprite et efface le curseur souris Windows (api window)
		DisplaySprite(#sprite_curseur,WindowMouseX(#win),WindowMouseY(#win)) ;  oui , alors on affiche le Sprite
		StartDrawing(WindowOutput(#win))
			FrontColor(RGB(255,255,255))
			DrawingMode(1)
			DrawText(1,1,"Position de la souris = " + Str(WindowMouseX(#win)) + " / " + Str(WindowMouseY(#win)))
		StopDrawing()
		Else ; non ! , donc on a quitté l'ecran (enfin.. on n'est plus dessus , car en mode fenetré on ne quitte jamais vraiment l'ecran.. puisqu'il est enfant d'une fenetre !! 
		; contrairement au mode Full Screen()
		
		;showcursor_(1) ; hors de l'ecran on affice le curseur Soouris window  mais pas le sprite  (api window)
	EndIf
	
	
	event= WaitWindowEvent(2) 
	select event
		Case #PB_Event_Gadget
		Select EventGadget()
			Case #bouton
			MessageRequester("info", "t'as cliqué sur le bouton")
		EndSelect
		Case #PB_Event_CloseWindow
		End
	EndSelect
	FlipBuffers()
	ClearScreen(RGB(0,0,0))
Until KeyboardPushed(#PB_Key_Escape)



;- les procedures
; ******************************************************************************************************

Procedure open_win()
	if OpenWindow(#win,0,0,800, 600,"Window",#PB_Window_SizeGadget|#PB_Window_SystemMenu )
		ButtonGadget(#bouton,10,WindowHeight(#Win)-60,50,50,"bouton")
		ContainerGadget(#container, 2, 2, WindowWidth(#Win)-70,WindowHeight(#Win)-72) 
		If OpenWindowedScreen(GadgetId(#container),0,0,1024, 768,0,0,0) = 0
			MessageRequester("Erreur", "Impossible d'ouvrir un ecran 640x480", 0)
			End
		EndIf
		CloseGadgetList()
		
	Endif
	SetWindowCallback(@MyWindowCallback())
	SetFrameRate(60)
	StickyWindow(#win,1)
EndProcedure

Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
	Result = #PB_ProcessPureBasicEvents
	Select Message
		Case #WM_SIZING
		ResizeGadget(#container,2,2,WindowWidth(#Win)-70,WindowHeight(#Win)-72) ; redimensionne le container ..et donc le windowedscreen()
		ResizeGadget(#bouton,#PB_Ignore,WindowHeight(#Win)-60,#PB_Ignore,#PB_Ignore) ; on reposition aussi le bouton tant qu'a faire
	EndSelect
	ProcedureReturn Result
EndProcedure
; EPB
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: redimensionner un OpenwindowScreen

Message par Thyphoon »

Un grand merci Dobro !! :D
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: redimensionner un OpenwindowScreen

Message par Backup »

De rien :)
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: redimensionner un OpenwindowScreen

Message par Thyphoon »

Dobro a écrit :De rien :)
Ba si quand même tu y a passé du temps et je tournais un peu en rond !
donc un GRAND merci même ;)
Répondre