Screen Saver With in Gambas Application

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Screen Saver With in Gambas Application

Post by AndyGable »

Hi all,

I know i can use the built in screen saver on Linux but I am not using a full desktop just X11

What I want to do is when I display a given screen (frmSignedOff) after 5mins (or what ever I set the time out to be) I would like to start display full screen bmp / png images over my application (but have the application keep focus and respond to the A key (Sign on)

The idea behind this would be to use the user display as a advertising screen when not in use.

Is this possible (as I would like to show a number of "slides"
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Screen Saver With in Gambas Application

Post by BruceSteers »

I think it would be best to just open a full screen window to show your slides and have that window monitor the key press event and if A is pressed close itself and go back to the app login.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Screen Saver With in Gambas Application

Post by BruceSteers »

Here's a working class that does that.
you could put any code you like in the SWin_Keypress event to do your login.

' Gambas class file

Public SWin As Window
Public PB As PictureBox
Public TM As Timer

'' Open the full screen window with a picturebox in it...
Public Sub OpenImageDisplayer()

  With SWin = New Window As "SWin"
    .FullScreen = True
    .Arrangement = Arrange.Fill
  End With

 With PB = New PictureBox(SWin) As "PB"
   .Expand = True
   .Mode = PictureBox.Contain
   .Alignment = Align.Center
 End With

 SWin.Show()

 TM = New Timer As "TM"
 TM.Delay = 3000
 TM.Start
 TM.Trigger

End

'' monitor for keypress events
Public Sub SWin_KeyPress()
  
  If Key.Text = "a" Then 
    TM.Stop
    SWin.Close
  Endif
  
End

'' A timer to randomly pic an image from my Pictures folder and load it in the PictureBox
Public Sub TM_Timer()
  
  Dim sPics As String[] = Dir(User.Home &/ "Pictures", "*.png", gb.file)
  sPics.Shuffle()
  PB.Picture = Picture.Load(User.Home &/ "Pictures" &/ sPics[0])
 
End

If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Screen Saver With in Gambas Application

Post by AndyGable »

BruceSteers wrote: Thursday 25th August 2022 11:07am Here's a working class that does that.
you could put any code you like in the SWin_Keypress event to do your login.

' Gambas class file

Public SWin As Window
Public PB As PictureBox
Public TM As Timer

'' Open the full screen window with a picturebox in it...
Public Sub OpenImageDisplayer()

  With SWin = New Window As "SWin"
    .FullScreen = True
    .Arrangement = Arrange.Fill
  End With

 With PB = New PictureBox(SWin) As "PB"
   .Expand = True
   .Mode = PictureBox.Contain
   .Alignment = Align.Center
 End With

 SWin.Show()

 TM = New Timer As "TM"
 TM.Delay = 3000
 TM.Start
 TM.Trigger

End

'' monitor for keypress events
Public Sub SWin_KeyPress()
  
  If Key.Text = "a" Then 
    TM.Stop
    SWin.Close
  Endif
  
End

'' A timer to randomly pic an image from my Pictures folder and load it in the PictureBox
Public Sub TM_Timer()
  
  Dim sPics As String[] = Dir(User.Home &/ "Pictures", "*.png", gb.file)
  sPics.Shuffle()
  PB.Picture = Picture.Load(User.Home &/ "Pictures" &/ sPics[0])
 
End

Thank-you so much BruceSteers I shall try that when I get home
Post Reply