Results 1 to 5 of 5

Thread: Windows screensaver

  1. #1
    Join Date
    Feb 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Windows screensaver

    Hi!

    I'm trying to write a Windows screensaver and I'm having trouble getting the preview mode to work.

    In preview mode, the screensaver gets a window handle from the system which describes the window where the screensaver should run in. This is the small "monitor" widget in the screensaver setup dialog.

    So I need my screensaver to not run fullscreen but inside this window. I found out that this should be possible by using QWidget::create() and passing the window handle as WId parameter. But everytime I try this I get the following output:

    QWidget::create: Failed to set window procedure (Access denied)

    What am I doing wrong here? Anyone know how this is supposed to work?

    Thanks
    --Michael

  2. #2
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows screensaver

    I've found some info. As far as I understood provided hWnd should be parent of your widget.

  3. #3
    Join Date
    Feb 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows screensaver

    OK, I understand that.

    So what I basically need to do is create a windows using Win32 API calls, which has the given hWnd as parent, and then pass that new window's hWnd over to QWidget::create(), right?

    Complicated, but I'll try it and see if it works.

  4. #4
    Join Date
    Feb 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows screensaver

    Okay, I changed my program a bit, but it still doesn't work right.

    Here's what I do (in the constructor of my main Qt window) to setup the screensaver in preview mode (where window is the hWnd which is passed to the screensaver):

    RECT rect;
    HWND previewWindow;
    GetClientRect(window, &rect);
    printf("%d %d %d %d\n", rect.left, rect.top, rect.right, rect.bottom);
    previewWindow = CreateWindow(L"Static", L"Preview", WS_VISIBLE | WS_CHILD, rect.left, rect.top, rect.right, rect.bottom, window, 0, 0, 0);
    printf("new hWnd = %d\n", previewWindow);
    create(previewWindow, false);
    show();


    This actually fills the preview-area black (my screensaver has a black background), but it seems that the screensaver now doesn't respond to any messages anymore. I.e. it doesn't repaint periodically, and when selecting a different screensaver in the dropdown-list, I have to manually kill my screensaver, otherwise the dialog window won't respond anymore, too (I guess it tries to send WM_QUIT to my saver which can't/won't respond)

    Anyone have any ideas what's going wrong here?

  5. #5
    Join Date
    Aug 2009
    Location
    Lancashire UK
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Windows screensaver

    Did you ever get anywhere with this ?
    I am trying to do something similar (embedding a QMainWindow into an existing HWND) with QWidget::create.
    I get the same error message, and the co-ordinates of my QMainWindow are offset by the position of my original HWND, and the QMainWindow is impervious to input events.

Similar Threads

  1. Qt Jambi, deploying app on Mac & Windows fails
    By ChrisColon in forum Installation and Deployment
    Replies: 2
    Last Post: 16th February 2009, 22:05
  2. Replies: 5
    Last Post: 15th January 2009, 09:03
  3. Opening text file fails after autostartup on windows
    By yogourta in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2008, 03:52
  4. Windows not appearing in XP.
    By beardybloke in forum Qt Programming
    Replies: 7
    Last Post: 24th October 2007, 17:32
  5. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.