Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Windows screensaver preview  (Read 8018 times)

0 Members and 1 Guest are viewing this topic.

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Windows screensaver preview
« on: March 04, 2013, 10:49:40 am »
I'm trying to make a preview for my screensaver, but i have a problem.
Render Window is created with parent handle, and WindowImplWin32::globalOnEvent is never called. I can't get any events in my application and correctly close it. Does anybody have any suggestions ?

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #1 on: March 04, 2013, 11:32:52 am »
PeekMessage(&message, m_handle, 0, 0, PM_REMOVE) does not return true.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Windows screensaver preview
« Reply #2 on: March 04, 2013, 11:38:06 am »
What happens if you put NULL instead of m_handle? (after that you must of course recompile SFML)

And does it always return 0? Don't forget that most of the time there's no message to process, so indeed it returns 0.
« Last Edit: March 04, 2013, 11:39:52 am by Laurent »
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #3 on: March 04, 2013, 01:35:14 pm »
no changes

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Windows screensaver preview
« Reply #4 on: March 04, 2013, 01:50:54 pm »
What about my last question? Did you make sure that it really always returned 0?
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #5 on: March 04, 2013, 02:11:10 pm »
Yes, it returns only 0  :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Windows screensaver preview
« Reply #6 on: March 04, 2013, 02:14:23 pm »
Could you write a complete and minimal app that reproduces this problem?
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #7 on: March 04, 2013, 02:18:25 pm »
I have more info :

WindowImplWin32::WindowImplWin32(WindowHandle handle) :
m_handle          (handle),
m_callback        (0),
m_cursor          (NULL),
m_icon            (NULL),
m_keyRepeatEnabled(true),
m_isCursorIn      (false),
m_lastSize        (0, 0),
m_resizing        (false)
{
    if (m_handle)
    {
        SetLastError(0);
        // We change the event procedure of the control (it is important to save the old one)
        SetWindowLongPtr(m_handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
        m_callback = SetWindowLongPtr(m_handle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&WindowImplWin32::globalOnEvent));
        int err = GetLastError();
        int a = err;
        a += 1;
    }
}
 

GetLastError() returns 5

Quote
ERROR_ACCESS_DENIED
5 (0x5)
Access is denied.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Windows screensaver preview
« Reply #8 on: March 04, 2013, 02:34:13 pm »
What handle do you use? Is this a specific window (like the desktop)?
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #9 on: March 04, 2013, 02:41:28 pm »
program is started with params "-p <handle>", it works as expected, but it doesn't receive events

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Windows screensaver preview
« Reply #10 on: March 04, 2013, 03:01:18 pm »
Quote
program is started with params "-p <handle>"
I have no idea what it means, and how that answers my question (even if handle is passed to the program like this, it doesn't say what handle is passed) ;D

I have also no idea what your screensaver does, nor what specific stuff is done by you or the OS in order to produce a screensaver preview. So please don't assume that I can understand what you say without detailed explanations.

It would be really great to see a complete and minimal app that reproduces the same problem, but without all the screensaver specific stuff -- if possible.
Laurent Gomila - SFML developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Windows screensaver preview
« Reply #11 on: March 07, 2013, 08:37:10 am »
I found the other way to make screensavers, see this : http://msdn.microsoft.com/en-us/library/cc144066(v=vs.85).aspx
P.S. you can insert this in the doc or else, because everyone start with parsing keys and creating window, and this solution is working perfect.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11053
    • View Profile
    • development blog
    • Email
AW: Re: Windows screensaver preview
« Reply #12 on: March 07, 2013, 09:02:42 am »
you can insert this in the doc or else, because everyone start with parsing keys and creating window, and this solution is working perfect.
I've no idea why this should be in the SFML doc, because not many (if any) will write a screensaver.
SFML's docs are about SFML and not about any random and OS specific task anyone will ever try. ;)

But feel free to write a full article about screensavers on all the different platforms and put it on the wiki.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/