Screen Saver Issue

Just starting out? Need help? Post your questions and find answers here.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Screen Saver Issue

Post by J. Baker »

So weird. This is the method I used for my last screen saver and it works just fine. New screen preview will not work at all, even though it is using the same code. Here's a shortened sample of the code...

Any thoughts?

Code: Select all

ExamineDesktops()

InitSprite()

DPI = DesktopResolutionX()

Global ParameterID.s = "", hWnd, pSize.RECT

Procedure Callback(hWnd, Message, wParam, lParam)
  
  Protected Retval
  
  Select Message
    Case #WM_CLOSE
      End
  EndSelect

  Retval = DefWindowProc_(hWnd, Message, wParam, lParam)
  
  ProcedureReturn Retval
  
EndProcedure

Procedure Preview()
    
    hWnd = Val(ParameterID)
    GetClientRect_(hWnd, @PSize.RECT)
    If OpenWindow(0, 0, ((pSize\bottom / DPI) - (((pSize\right / DPI) / 16) * 9)) / 2, pSize\right / DPI, ((pSize\right / DPI) / 16) * 9, "", #WS_CHILD, hWnd)
      OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0) +110, DesktopHeight(0) -55, 1, 0, 0) ; 152 x 112 preview size in Windows XP
      SetWindowCallback(@Callback())
      
      ;SetWindowState(0, #PB_Window_Maximize) ;temp fix PureBasic 5.72
      ;SetWindowState(0, #PB_Window_Normal) ;temp fix PureBasic 5.72
    EndIf
    
    CatchSprite(0, ?PreviewStart)
    
    AddWindowTimer(0, 1, 16)
    
    Repeat
      
      ClearScreen(RGB(50, 100, 200))
      WaitWindowEvent()
      DisplaySprite(0, 0, 0)
      FlipBuffers()
      
    ForEver
    
EndProcedure
  
Para.s = ProgramParameter()

Parameter.s = LCase(Left(ReplaceString(Para.s,"-","/"), 2))
  
  Select Parameter
    Case "/p"
      ParameterID = ProgramParameter()
      Preview()
    Case "/c"
      MessageRequester("", "Settings")
    Case "/s"
      MessageRequester("", "Screen Saver")
      
  EndSelect
  
DataSection
  PreviewStart:
    IncludeBinary "C:\Users\jbake\Desktop\Preview.bmp"
  PreviewEnd:
EndDataSection
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Screen Saver Issue

Post by chi »

Maybe it's the now default OpenGL subsystem?
Et cetera is my worst enemy
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Screen Saver Issue

Post by J. Baker »

chi wrote: Fri Aug 05, 2022 2:54 am Maybe it's the now default OpenGL subsystem?
I can still compile my last screen saver and it works just fine. Same preview code but it's like it just doesn't want to work. I've looked over it for a few hours today and either I'm totally over-looking something or... well I don't know what the or would be. I'm dumb founded on this.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Screen Saver Issue

Post by J. Baker »

I believe I just found it. I didn't make the DPI global. :oops:

Oh my goodness!
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Screen Saver Issue

Post by chi »

Global DPI.d = DesktopResolutionX();

Without Global: Division by zero in Procedure Preview()
Without .d: Returns only int (1.25 = 1, 1.5 = 2, ...)
Et cetera is my worst enemy
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Screen Saver Issue

Post by J. Baker »

chi wrote: Fri Aug 05, 2022 4:50 am Global DPI.d = DesktopResolutionX();

Without Global: Division by zero in Procedure Preview()
Without .d: Returns only int (1.25 = 1, 1.5 = 2, ...)
Correct. I was just over-looking it and possibly having a blond moment. As for the Double/Float, I'm aware, it just wasn't my main concern when posting the example code but thanks! ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Screen Saver Issue

Post by chi »

J. Baker wrote: Fri Aug 05, 2022 4:04 am I've looked over it for a few hours today and either I'm totally over-looking something or...
That's why EnableExplicit is your friend ;). Well, at least it's working again.
Et cetera is my worst enemy
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Screen Saver Issue

Post by Mijikai »

CloseScreen() is missing.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Screen Saver Issue

Post by J. Baker »

Mijikai wrote: Fri Aug 05, 2022 7:23 am CloseScreen() is missing.
Yep. I really just posted a quick example to find out why the preview wasn't working. My apologies for not being more accurate, as I quickly wrote it up. Problem solved now though. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Post Reply