It is currently Thu May 23, 2013 1:52 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun Mar 14, 2010 8:59 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4835
Location: Germany
I'm often in a good mood.

_________________
oh... and have a nice day.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun Mar 14, 2010 9:28 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 5808
You could have fooled me.

_________________
( PB5.11 Win7 x64 Dell XPS710 Raid 0 VelociRaptor Intel Q6600 nForce 5 NVidia GTS450 )
( You have two options: psychotherapy, or the PureBasic Survival Guide... )


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun Mar 14, 2010 9:43 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4835
Location: Germany
so you really think it's a friendly idea to pick on me when I already said I'm not in a good mood?

_________________
oh... and have a nice day.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun Mar 14, 2010 9:49 pm 
Offline
Addict
Addict

Joined: Sat Oct 17, 2009 10:51 pm
Posts: 919
Kaeru Gaman: Just put him on ignore :wink:

_________________
If you are new to PB you should check out the CodeArchiv. It has examples for almost everything you would want to do in PB.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun Mar 14, 2010 10:42 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
Fast working example, only working with debugger disabled.
Code:
;please disable debugger!
InitSprite()
InitMouse()
InitKeyboard()

OpenScreen(1024, 768, 32, "fllscrn")

CreateSprite(0, 64, 64)
StartDrawing(SpriteOutput(0))
  Line( 0, 0, 48, 32,$0FF0FF)
  Line( 0, 0, 64, 64,$0FF0FF)
  Line( 0, 0, 32, 48,$0FF0FF)
StopDrawing()

Repeat

  ExamineMouse()
  ExamineKeyboard()

  While WindowEvent()
  Wend

  ClearScreen(0)
  DisplayTransparentSprite(0, MouseX(), MouseY())
  FlipBuffers()

  If IsScreenActive() = 0

    ReleaseMouse(1)

    Repeat

      While WindowEvent()
      Wend
      Delay(100)

    Until IsScreenActive() <> 0

    Delay(2000)
    CloseScreen()
    OpenScreen(1024, 768, 32, "fllscrn")
    ReleaseMouse(0)

    CreateSprite(0, 64,64)
    StartDrawing(SpriteOutput(0))
      Line( 0, 0, 48, 32, $0FF0FF)
      Line( 0, 0, 64, 64, $0FF0FF)
      Line( 0, 0, 32, 48, $0FF0FF)
    StopDrawing()

  EndIf

Until KeyboardPushed(#PB_Key_Escape)


edit: to say to disable the debugger

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Last edited by djes on Mon Mar 15, 2010 11:51 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 10:00 am 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4835
Location: Germany
Quote:
Fast working example

Quote:
[ERROR] At least one window should be opened to use this command.

yep, fast ended... but not working. ;)

I get the idea... closing and re-opening the screen to avoid losing the context, resp. leaving the old context and creating a new one.
a thought I already played with*, especially for changing the resolution while running.
(* I already played with that thought)

to use this, it would be necessary to keep the amount of recently loaded content as low as possible,
and handle the re-loading from within memory, not from disk.
the reloading of the content must not take longer than the changing of the resolution, what takes two seconds or so.
should be solvable via Ressources scripts.


thanks for the idea, I will keep it in mind.

_________________
oh... and have a nice day.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 11:45 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
I forgot to say to disable the debugger... There's always a window on Windows :)

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 12:03 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4835
Location: Germany
ah.. I see.
well, I don't see why flushing the events helps anything, and why I don't do it normally.

the very solution in this code seems to be the re-opening of the screen.
in the end, something I wanted to avoid.
I wouldn't have taken any of the efforts about this*, if I accepted re-opening from the beginning on.

*
screen in a container viewtopic.php?p=273743#p273743
eliminate border of a window viewtopic.php?f=12&t=41174
problem changing resolution API-wise viewtopic.php?f=16&t=41179

_________________
oh... and have a nice day.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 12:09 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
No, the very solution is not *only* the re-opening of the screen. There's a fault on "flipbuffers" that should handle the events correctly (when alt-tabbed ;)), and give to the IsScreenActive() function the good signal to restore the screen. It doesn't work, and it's why the windowevent() is necessary (not to flush but to capture!).

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 12:12 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4835
Location: Germany
hm... so this should work without the re-opening? o.O

_________________
oh... and have a nice day.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 12:21 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
I think so. I've already signaled this in the bugs section.

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 12:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 442
Location: ger
without debugger it crashes here. so i opened an invisible window before opening the screen to legalize the WindowEvent(), and then it works better but sometimes the debugger says 'invalid memory access' at DisplayTransparentSprite(), and without debugger it crashes. sometimes it works flawlessly though.


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 2:17 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
It's more a 'proof of concept' code. Try to add move the delay between the closescreen() and the openscreen().

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Mon Mar 15, 2010 2:56 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1334
Location: Pas-de-Calais, France
Debugger activated code
Code:
InitSprite()
InitMouse()
InitKeyboard()

OpenScreen(1024, 768, 32, "fllscrn")

CreateSprite(0, 64, 64)
StartDrawing(SpriteOutput(0))
  Line( 0, 0, 48, 32,$0FF0FF)
  Line( 0, 0, 64, 64,$0FF0FF)
  Line( 0, 0, 32, 48,$0FF0FF)
StopDrawing()

Repeat

  ExamineMouse()
  ExamineKeyboard()

  ClearScreen(0)
  DisplayTransparentSprite(0, MouseX(), MouseY())
  FlipBuffers()

  If IsScreenActive() = 0

    ReleaseMouse(1)

    Repeat

      While PeekMessage_(msg.MSG, 0, 0, 0, #PM_REMOVE)
        TranslateMessage_(msg)
        DispatchMessage_(msg)
      Wend
      Delay(100)

    Until IsScreenActive() <> 0

    CloseScreen()
    Delay(1000)
    OpenScreen(1024, 768, 32, "fllscrn")
    ReleaseMouse(0)

    CreateSprite(0, 64,64)
    StartDrawing(SpriteOutput(0))
      Line( 0, 0, 48, 32, $0FF0FF)
      Line( 0, 0, 64, 64, $0FF0FF)
      Line( 0, 0, 32, 48, $0FF0FF)
    StopDrawing()

  EndIf

Until KeyboardPushed(#PB_Key_Escape)

_________________
The Shooting Crew ~> http://www.shootingcrew.com/
Bobble Puzzle, Purebreaker 3 ~> http://djes.free.fr


Top
 Profile  
 
 Post subject: Re: leave FullScreen with Alt-Tab is not functional?
PostPosted: Sun May 02, 2010 9:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 511
this code work fine : (No API)

Quote:


; Purebasic 4.41
;By Dobro
; exemple de l'utilisation de IsScreenActive()

; quittez le pseudo jeux avec Alt+TAB
; on retourne dans le jeux d'un clique sur la fenetre en barre des taches

initsprite ()
initmouse ()
initkeyboard ()
Enumeration
         #sprite
EndEnumeration
Structure sprite
        x.i
        y.i
        pas_x.i
        pas_y.i
EndStructure
Dim sprite.sprite(1)
examinedesktops ()
x_screen= desktopwidth (0) ; je recup la rez de l'ecran
y_screen= desktopheight (0)
flag=0
debut: ; le label qui permet le retour dans le jeux !!
openscreen (x_screen, y_screen, 32, "Fullscreen + ALT-TAB démo" )
releasemouse (0)
createsprite ( #sprite , 64, 64)
startdrawing ( spriteoutput ( #sprite ))
         box (0,0,64,64, rgb (255,13,40))
stopdrawing ()


;********* initialisation du sprite **********
If flag=0 ; le joueur n'est jamais sorti du jeu , s'il est sorti on ne fais pas ce bloc de code !!
sprite(1)\x=x_screen/2 ; on place le sprite au centre
sprite(1)\y=y_screen/2 ; on place le sprite au centre
sprite(1)\pas_x=2 ; on donne une vitesse de deplacement a notre sprite
sprite(1)\pas_y=2 ; on donne une vitesse de deplacement a notre sprite
EndIf

Repeat
         examinekeyboard () ; ne sert que pour quitter le prg avec la touche esc
    
         ; ************* gere le deplacement du sprite ***************
        sprite(1)\x=sprite(1)\x+sprite(1)\pas_x
        sprite(1)\y=sprite(1)\y+sprite(1)\pas_y
                 ; ----------------------------------------------------------------------------
         If sprite(1)\x+64>=x_screen:sprite(1)\pas_x=-sprite(1)\pas_x: EndIf
         If sprite(1)\y+64>=y_screen:sprite(1)\pas_y=-sprite(1)\pas_y: EndIf
         ; ----------------------------------------------------------------------------
         If sprite(1)\x<=0:sprite(1)\pas_x=-sprite(1)\pas_x: EndIf
         If sprite(1)\y<=0:sprite(1)\pas_y=-sprite(1)\pas_y: EndIf
         ; *******************************************************
        
        
         ; ********** affichage du sprite *********************
         displaytransparentsprite ( #sprite , sprite(1)\x, sprite(1)\y)
        
         flipbuffers ()
         clearscreen (0)
        
         ; *************** attention toute l'astuce est la !! *******************
         If isscreenactive () = 0 ; le joueur a quitter le jeu (Alt-tab)
                 releasemouse (1) ; je libere la souris ... inutile ici mais bon
                flag=1 ; on note que l'utilisateur est sorti du jeux
                 closescreen () ; on ferme l'ecran
                
                 ; ******* la ruse de guerre !! ****************************
                 openwindow (1,1,1,1,1, "toto le jeu " , #PB_Window_Minimize ) ; j'ouvre une fenetre que je minimise en bar des taches
                 Repeat :Event= waitwindowevent (2): Until Event= #PB_Event_ActivateWindow ; j'attend qu'on clique sur la fenetre
                 closewindow (1) ; je ferme la fenetre
                 Goto debut ; je retourne dans le jeux sans réinitialiser les variables de déplacement (on reprends ou on en etait! !!! )
     EndIf
Until keyboardpushed ( #PB_Key_Escape ) ; là , on veux vraiment quitter le jeux LOL
End



_________________
Image
************************************
site : http://michel.dobro.free.fr/
Videos : http://www.youtube.com/user/DobroMG
************************************


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye