SFML community forums

Help => Window => Topic started by: Acrobat on March 04, 2013, 10:49:40 am

Title: Windows screensaver preview
Post by: Acrobat 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 ?
Title: Re: Windows screensaver preview
Post by: Acrobat on March 04, 2013, 11:32:52 am
PeekMessage(&message, m_handle, 0, 0, PM_REMOVE) does not return true.
Title: Re: Windows screensaver preview
Post by: Laurent 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.
Title: Re: Windows screensaver preview
Post by: Acrobat on March 04, 2013, 01:35:14 pm
no changes
Title: Re: Windows screensaver preview
Post by: Laurent on March 04, 2013, 01:50:54 pm
What about my last question? Did you make sure that it really always returned 0?
Title: Re: Windows screensaver preview
Post by: Acrobat on March 04, 2013, 02:11:10 pm
Yes, it returns only 0  :(
Title: Re: Windows screensaver preview
Post by: Laurent on March 04, 2013, 02:14:23 pm
Could you write a complete and minimal app that reproduces this problem?
Title: Re: Windows screensaver preview
Post by: Acrobat 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
Title: Re: Windows screensaver preview
Post by: Laurent on March 04, 2013, 02:34:13 pm
What handle do you use? Is this a specific window (like the desktop)?
Title: Re: Windows screensaver preview
Post by: Acrobat 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
Title: Re: Windows screensaver preview
Post by: Laurent 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.
Title: Re: Windows screensaver preview
Post by: Acrobat 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.
Title: AW: Re: Windows screensaver preview
Post by: eXpl0it3r 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.