Hiding a windowed screen

Everything else that doesn't fall into one of the other PB categories.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Hiding a windowed screen

Post by tinman »

Hello,

Does anyone know how to hide a windowed screen? I need something like the HideGadget() command, but haven't been able to figure it out or find anything on the forums about this.

This is as far as I have got so far, although the problem is that ScreenID() returns the same value as WindowID(). Any suggestions would be most welcome.

Thanks.

Code: Select all

If InitSprite()=0 : End : EndIf

If OpenWindow(0, 0, 0, 400, 350, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "")
    If CreateGadgetList(WindowID())
        ButtonGadget(1, 10, 310, 380, 30, "Show/hide")
    EndIf
    
    If OpenWindowedScreen(WindowID(), 0, 0, 400, 300, 0, 0, 50)
        wid.l = WindowID()
        Debug wid
        
        sid.l = ScreenID()
        Debug sid
        
        SetFrameRate(60)
        StartDrawing(ScreenOutput())
        
        gtc.l = GetTickCount_()
        RandomSeed(gtc)
        For i.l=1 To 100000
            Plot(Random(399), Random(299), RGB(Random(255),Random(255),Random(255)))
        Next
        StopDrawing()
    EndIf

    Repeat
        ev = WaitWindowEvent()
        
        While ev
            Select ev
                Case #PB_Event_Gadget
                    show_hide = 1 - show_hide
                    If show_hide
                        ; hide
                        ShowWindow_(sid, SW_HIDE)
                    Else
                        ; show
                        ShowWindow_(sid, SW_SHOW)
                    EndIf
                    
                Case #PB_Event_Repaint
                    FlipBuffers()
                    FlipBuffers()
                    
                Case #PB_Event_CloseWindow
                    quit = 1
            EndSelect
            
            ev = WindowEvent()
        Wend
    Until quit=1
EndIf
End
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

tinman,

This is the way I would do more or less, using minimize instead of hide which makes the window not visible, but as it is not visible, it is also not possible to click anything to toggle hide state.

Code: Select all

  #Button_Minimize = 1
  If InitSprite()
      If OpenWindow(0, 0, 0, 400, 350, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "") 
          If CreateGadgetList(WindowID()) 
              ButtonGadget(#Button_Minimize, 10, 310, 380, 30, "Show/hide") 
          EndIf 
          If OpenWindowedScreen(WindowID(), 0, 0, 400, 300, 0, 0, 50) 
          SetFrameRate(60) 
          StartDrawing(ScreenOutput()) 
          gtc.l = GetTickCount_() 
          RandomSeed(gtc) 
          For i.l=1 To 100000 
          Plot(Random(399), Random(299), RGB(Random(255),Random(255),Random(255))) 
          Next 
          StopDrawing() 
          EndIf 
          Repeat 
            Select WaitWindowEvent()
              Case #PB_Event_Gadget 
                Select EventGadgetID()
                  Case #Button_Minimize
                    ShowWindow_(WindowID(), #SW_MINIMIZE ) 
                EndSelect
              Case #PB_Event_Repaint 
                FlipBuffers() 
              Case #PB_Event_CloseWindow 
                quit = 1 
            EndSelect 
          Until quit=1 
      EndIf
  EndIf 
End 
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

You missed the point. I need to hide the screen, not the window. Like HideGadget() would hide a gadget and not the window.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

Allright, you need to hide the window. This si OK.

Hide it by using SW_HIDE. It works.

But except by making it visible back from outside, you will never find an event that will turn from hidden to visible from this window itself because it is hidden ... So in case you manage this window from another process you will send messages to no more hide it, otherwise it will never work.

Or maybe you expected to turn the window visible from an internal event, but this is the same situation I describe by doing it from outside. No user input is possible as soon as the window has been hidden.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

I do not want to hide the window. I want to hide the screen only! Think of the screen like a gadget. I want a program which does this:

Code: Select all

If OpenWindow(0, 0, 0, 400, 350, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "")
    If CreateImage(1, 400, 300)
        StartDrawing(ImageOutput())
        
        gtc.l = GetTickCount_()
        RandomSeed(gtc)
        For i.l=1 To 100000
            Plot(Random(399), Random(299), RGB(Random(255),Random(255),Random(255)))
        Next
        StopDrawing()

        If CreateGadgetList(WindowID())
            ButtonGadget(1, 10, 310, 380, 30, "Show/hide")
            ImageGadget(2, 0, 0, 400, 300, UseImage(1))
            sid = GadgetID(2)
        EndIf
    
    EndIf

    Repeat
        ev = WaitWindowEvent()
        
        While ev
            Select ev
                Case #PB_Event_Gadget
                    show_hide = 1 - show_hide
                    If show_hide
                        ; hide
                        ;ShowWindow_(sid, SW_MINIMIZE)
                        HideGadget(2, 1)
                    Else
                        ; show
                        ;ShowWindow_(sid, SW_NORMAL)
                        HideGadget(2, 0)
                    EndIf
                    
                Case #PB_Event_CloseWindow
                    quit = 1
            EndSelect
            
            ev = WindowEvent()
        Wend
    Until quit=1
EndIf
End
But using a windowed screen instead of an image gadget.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

I guess the screen is not a regular object that can support such behaviour. Or may you try to use one trick being to cover the screen part of the window with an image gadget or something like this ...
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
VPureBasic
User
User
Posts: 59
Joined: Fri Apr 25, 2003 6:09 pm
Location: Quebec - Canada

Post by VPureBasic »

Hi Tinman.

Try this... it's work great on my side!

Code: Select all

If InitSprite()=0 : End : EndIf 

If OpenWindow(0, 0, 0, 400, 350, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "") 
    If CreateGadgetList(WindowID()) 
        ButtonGadget(1, 10, 310, 380, 30, "Show/hide") 
    EndIf 
    
    ;- Add These lines...
    If OpenWindow( 1,0,0,400,300,#PB_Window_Invisible,"" )
         SetWindowLong_( WindowID(1), #GWL_STYLE, #WS_CHILD|#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS )
         SetParent_( WindowID(1), WindowID(0) )
          
         If OpenWindowedScreen(WindowID(1), 0, 0, 400, 300, 0, 0, 50) 
    
               wid.l = WindowID(0) 
               ;Debug wid 
        
               sid.l = WindowID(1)
               ;Debug sid 
        
               SetFrameRate(60) 
               StartDrawing(ScreenOutput()) 
        
               gtc.l = GetTickCount_() 
               RandomSeed(gtc) 
               For i.l=1 To 100000 
                    Plot(Random(399), Random(299), RGB(Random(255),Random(255),Random(255))) 
               Next 
               StopDrawing() 
         EndIf
    EndIf 

    Repeat 
        ev = WaitWindowEvent() 
        
        While ev 
            Select ev 
                Case #PB_Event_Gadget 
                    show_hide = 1 - show_hide 
                    If show_hide 
                        ; hide 
                        HideWindow( 1, 1 ) 
                    Else 
                        ; show 
                        HideWindow( 1, 0 ) 
                    EndIf 
                    
                Case #PB_Event_Repaint 
                    FlipBuffers() 
                    FlipBuffers() 
                    
                Case #PB_Event_CloseWindow 
                    quit = 1 
            EndSelect 
            
            ev = WindowEvent() 
        Wend 
    Until quit=1 
EndIf 
End 
Roger
Everything is possible with PureBASIC... All you're missing is imagination!
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

VPureBasic wrote:Try this... it's work great on my side!
Thanks Roger, neat idea. Works very nicely here too.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

In addition to that it would be nice to have more than one screen...
But OpenWindowedScreen returns 1 or 0 and not the handle of the screen.
Would be nice if that would be changed (if possible...)
And ScreenOutput() needs to be changed to, to accept handles like:
ScreenOutput(Screen1)
etc.
and other screen commands should be changed too if needed...

But as I said, don't know if Windows allows it or not 8O
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

AFAIK, only a single screen can be opened at a time, because it uses all the video ressources, or am I wrong ?

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Well, you can have 2 different programs with windowed screen running at the same time, can you not :?:
So it's not a graphic card issue, it's a os or pb issue ... suppose a pb one :(
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

fsw wrote:Well, you can have 2 different programs with windowed screen running at the same time, can you not :?:
Yep, you can have more than 1 windowed screen in multiple programs...but perhaps there is some OS limit which stops multiple screens in the same program?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Post Reply