Page 1 sur 4

Ouvrir un screen plus grand que la fenetre

Publié : lun. 06/mai/2019 16:52
par Christophe
Bonjour à tous, existe t'il un moyen pour créer un OpenWindowedScreen plus grand que la fenêtre ? En fait comme la commande cmd de windows.
D'après l'aide de PureBasic ce n'est pas possible alors comment "cmd" s'y prend t-il ?

j'ai essayé avec un ScrollArea mais ça ne fonctionne pas... :x

Code : Tout sélectionner

InitSprite()
OpenWindow(0, 0, 0, 1000, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ScrollAreaGadget(1, 0, 0, 1000, 500, 950, 800)
OpenWindowedScreen(GadgetID(1), 0, 0, 1000, 800, 0, 0, 0)
ClearScreen(#Black)

CreateSprite(0,40,40)
StartDrawing(SpriteOutput(0))
Box(0,0,40,40,#White)
StopDrawing()


DisplaySprite(0, 10, 10)

Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Ouvrir un screen plus grand que la fenetre

Publié : lun. 06/mai/2019 17:45
par Ollivier
Oui, il existe un moyen. Je vois ça dans quelques heures... Si quelqu'un a déjà un solution, plus on est de fous, plus on rit...

Re: Ouvrir un screen plus grand que la fenetre

Publié : lun. 06/mai/2019 20:50
par Ollivier
Si ça ne te dérange pas Christophe, je reporte. Demain, nous verrons le travail fait par Yffig EL QUECHOZ pour répondre à ta demande.

Re: Ouvrir un screen plus grand que la fenetre

Publié : lun. 06/mai/2019 23:00
par Christophe
Pas de problème Ollivier.

Re: Ouvrir un screen plus grand que la fenetre

Publié : mar. 07/mai/2019 20:20
par case
Christophe a écrit :Bonjour à tous, existe t'il un moyen pour créer un OpenWindowedScreen plus grand que la fenêtre ? En fait comme la commande cmd de windows.
D'après l'aide de PureBasic ce n'est pas possible alors comment "cmd" s'y prend t-il ?
tout simplement parce-que cmd est une fenêtre en mode console.

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Console example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;
    text$  = "Feel the Power of PureBasic!"        ; just a small text$ string
    dlay   = 4000                                  ; delay will set to 4000

;
;-------- Open our Console --------
;

    OpenConsole()                                  ; First we must open a console
    ConsoleTitle ("PureBasic - Console Example:")  ; Now we can give the opened console a Titlename ;)                                                  
    EnableGraphicalConsole(1)

;                                                                                                   
;-------- Ask and display the UserName --------
;
    
    ConsoleLocate (18,12)                          ; x y position 
    Print ("Please enter your name:   ")           ; Ask for name
    name$=Input()                                  ; Wait for user input

    ClearConsole()                                 ; This will clean the ConsoleScreen
    
    ConsoleLocate (24,10)                          ; x y position 
    PrintN ("Welcome "+name$)                      ; Print our text and the UserName
    ConsoleLocate (24,12)                          ; x y position
    PrintN (text$)                                 ; Print our text

    Delay (dlay)                                   ; Waits for moment

;
;-------- Cls and Cycle the Text-BG-Color 0 to 15 --------
;                                                  

    ClearConsole()                                 ; This will clean the ConsoleScreen
                                                   ; Info: Standard colors are (8 for text, 0 for backround)
    For i = 0 To 15
        ConsoleColor (0,i)                         ; Change BackGround text color (max 15) in every loop         
        ConsoleLocate (24,4+i)                     ; x y position 
        Print (text$)                              ; Print our text
    Next i

    Delay (dlay)                                   ; Waits for moment

;
;-------- Cls and Cycle the Text-FG-Color 0 to 15 --------
;

    ConsoleColor(0,0)                              ; Set back to black (0,0) for complete background...
    ClearConsole()                                 ; This will clean the ConsoleScreen
                                                   ; Info: Standard colors are (8 for text, 0 for backround)
    For i = 0 To 15
        ConsoleColor (i,0)                         ; Change ForGround text color (max 15) in every loop         
        ConsoleLocate (24,4+i)                     ; x y position 
        Print (text$)                              ; Print our text
    Next i

    Delay (dlay)                                   ; Waits for moment

;
;-------- Cls and Cycle the Background-Color 0 to 15 --------
;

    For a = 1 To 15
        ConsoleColor(a,a)                          ; Cycle background color...
        ClearConsole()                             ; This will clean the ConsoleScreen
        ;                                          ; Info: Standard colors are (8 for text, 0 for backround)
        For i = 0 To 15
            ConsoleColor (i,a)                     ; Change ForGround text color (max 15) in every loop         
            ConsoleLocate (24,4+i)                 ; x y position 
            Print (text$)                          ; Print our text
        Next i
        ;
        Delay(dlay/10)                             ; Waits for moment
    Next a    

    ;-------- Exit --------

    CloseConsole()
End

Re: Ouvrir un screen plus grand que la fenetre

Publié : mar. 07/mai/2019 23:04
par Ollivier
Ça marche chez tout le monde ça ?

Code : Tout sélectionner

;*****************************************************************************************************************************************************************************************************
#MainWin = 0
#ScreenWin = 1
ScreenW = 2048
ScreenH = 2048
InitSprite()
If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
        If CreateMenu(#MainWin, WindowID(#MainWin))
                MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 1, 2, #PB_MDI_AutoSize | #PB_MDI_BorderLess)
                AddGadgetItem(0, #ScreenWin, "Screen", 0, #PB_Window_BorderLess | #PB_Window_Tool)
                UseGadgetList(WindowID(#MainWin))
        EndIf
        ResizeWindow(#ScreenWin, 0, 0, ScreenW, ScreenH)
        OpenWindowedScreen(WindowID(#ScreenWin), 0, 0, ScreenW, ScreenH)
        HideMenu(#MainWin, #True)
        CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
        If StartDrawing(SpriteOutput(101) )
                For I = 1 To 1000
                        x = Random(ScreenW)
                        y = Random(ScreenH)
                        r = 50 + Random(50)
                        c = RGB(Random(255), Random(255), Random(255) )
                        Circle(x, y, r, c)
                        Circle(x - ScreenW, y, r, c)
                        Circle(x + ScreenW, y, r, c)
                Next
                StopDrawing()
        EndIf
        x = 0
        Repeat
                DisplaySprite(101, x, 0)
                DisplaySprite(101, ScreenW + x, 0)
                x - 1
                If x <= 0 - ScreenW
                        X = 0
                EndIf
                FlipBuffers()
                Delay(3)
        Until WindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 1:33
par Christophe
Super Ollivier, ça fonctionne très bien chez moi ! Par contre j'ai une petite question... pourquoi as tu créé un menu ? au départ je pensais que c'etait une astuce de programmation mais je me suis aperçu que ça fonctionnait sans

Code : Tout sélectionner

#MainWin = 0
#ScreenWin = 1
ScreenW = 2048
ScreenH = 2048
InitSprite()

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
  
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_AutoSize | #PB_MDI_BorderLess)
  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH) ;, 0, 0, 0, #PB_Screen_NoSynchronization) 
  
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
  
  x = 0
  Repeat
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
    Delay(3)
  Until WindowEvent() = #PB_Event_CloseWindow
EndIf
Encore un grand merci c'est exactement ce qu'il me fallait :D

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 4:39
par Ollivier
Pourquoi un menu ?

Dans ta version sans menu, qu'est-ce que ça donne si tu redimensionnes la fenêtre à l'aide de la souris ?

Est-ce que l'écran prend les proportions des nouvelles dimensions de la fenêtre ?

[Edit] : j'ai soumis ton code sur le forum US pour tests :https://www.purebasic.fr/english/viewto ... 13&t=72764

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 7:16
par MLD
Super Ollivier c'est top

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 7:24
par Ollivier
@MLD

Sympa d'avoir testé ! Mais le code de Christophe mérite aussi : son code semble bien fonctionner aussi.

@Christophe

Je te recommande de mettre ton code dans Trick&Tips du forum US.
Elle est bien cette astuce :
OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH)
Ça marche même avec une image dans un ImageGadget !

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 10:49
par MLD
Mille excuses les deux codes sont top :oops:

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 11:06
par Christophe
Pourriez vous tester (j'ai une petite config...)
La même chose mais non bloquant lors du redimensionnement ou deplacement. Par contre la valeur du delay ligne 29 doit être augmenter. Peut être une erreur de programmation de ma pars... je ne suis vraiment pas familiarisé avec les Semaphore :oops:

Code : Tout sélectionner

#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048
Global Thread
Global ThreadSemaphore = CreateSemaphore()

InitSprite()

Procedure UpdateScreen()
  WaitSemaphore(ThreadSemaphore)
  ResizeGadget(0, #PB_Ignore, #PB_Ignore,  WindowWidth(#MainWin), WindowHeight(#MainWin))
  SignalSemaphore(ThreadSemaphore)
EndProcedure

Procedure Scrolling(nul)
  
  Repeat
    WaitSemaphore(ThreadSemaphore)
    TrySemaphore(ThreadSemaphore)
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
    SignalSemaphore(ThreadSemaphore)
    Delay(20)   ; 3
    ForEver
 
EndProcedure

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
  
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )

  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH) 
  
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
  
  x = 0
  DisplaySprite(101, x, 0)
  DisplaySprite(101, ScreenW + x, 0)
  FlipBuffers()
  
   BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
   Thread = CreateThread(@Scrolling(),0)
   SignalSemaphore(ThreadSemaphore)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  KillThread(Thread) : FreeSemaphore(ThreadSemaphore)
EndIf
Et maintenant sans Thread

Code : Tout sélectionner

#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048
Global Thread
Global ThreadSemaphore = CreateSemaphore()

InitSprite()

Procedure UpdateScreen()
  ResizeGadget(0, #PB_Ignore, #PB_Ignore,  WindowWidth(#MainWin), WindowHeight(#MainWin))
EndProcedure

Procedure Scrolling()
  Static x
  
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
 
EndProcedure

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
  AddWindowTimer(#MainWin,1,1)
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )

  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH,0,0,0,#PB_Screen_NoSynchronization) 
  
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
  
  x = 0
  DisplaySprite(101, x, 0)
  DisplaySprite(101, ScreenW + x, 0)
  FlipBuffers()
  
  BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
  BindEvent(#PB_Event_Timer,@Scrolling())

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 12:39
par MLD
@ Christophe
Honnêtement je ne vois pas de différence de fonctionnement avec l'un ou l'autre code.
Pour le Delay (3) ou 20 je n'est vu aucune différence de fonctionnement.

Re: Ouvrir un screen plus grand que la fenetre

Publié : mer. 08/mai/2019 13:09
par Christophe
@MLD
merci d'avoir testé, comme je l'ai dit j'ai une petite config donc si le delay est inferieur à 20 dans la version threadé lors d'un redimensionnement il arrive que le debugger plante ce qui n'arrive pas avec la version "bindevent" mais c'est un peu moins fluide

Re: Ouvrir un screen plus grand que la fenetre

Publié : ven. 10/mai/2019 11:41
par falsam
Le sujet je pense est maintenant résolu.

En complément d'information, Rashad sur le forum anglophone propose en 2014 un code à grand renfort d'API windows sans fenetre MDI permettant de scroller un OpenWindowedScreen().
:arrow: https://www.purebasic.fr/english/viewto ... 08#p445108

L'idée de OpenWindowedScreen() dans un MDI est suggérée aussi par Rashad
:arrow: https://www.purebasic.fr/english/viewto ... 24#p445124