Results 1 to 5 of 5

Thread: WIN32 ClanLib 0.9 Message Queue has_messages()

  1. #1
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default WIN32 ClanLib 0.9 Message Queue has_messages()

    Currently, the Basic2D example on the Win32 platform does not work.

    You cannot move the window on Vista.

    The problem is caused by:
    bool CL_DisplayMessageQueue::has_messages()

    Currently, the code is:
    Code:
    bool CL_DisplayMessageQueue::has_messages()
    {
    	return wait(0);
    }
    If i replace the function with:

    Code:
    bool CL_DisplayMessageQueue::has_messages()
    {
    	CL_DisplayWindowMessage message = peek_message(false);
    	return (!message.is_null());
    }
    The Basic2D example works

    But why?
    I would have thought wait(0) would have been a better function to use.

    (I have not changed the SVN)

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    That is a very good question.

    I know that when you click outside the client area (i.e. if you start resizing the window), then Windows will block during the GetMessage call and perform its own modal loop.

    Now, I would personally expect MsgWaitForMultipleEvents to also unblock in the situations where such a modal loop is pending (since it is started by a mouse click in the non-client area), but your alternative version of has_messages() seem to indicate it does not - or that we have a bug in how we use MsgWaitForMultipleEvents. I really hope it is the later because the former would put us in big trouble.

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I think that i have found the problem:

    Change:
    DWORD result = MsgWaitForMultipleObjects(0, 0, FALSE, timeout_win32, QS_ALLEVENTS);

    To
    DWORD result = MsgWaitForMultipleObjectsEx(0, 0, timeout_win32, QS_ALLEVENTS, MWMO_INPUTAVAILABLE);

    "MsgWaitForMultipleObjectsEx does not return if there is unread input of the specified type in the message queue after the thread has called a function to check the queue, unless you use the MWMO_INPUTAVAILABLE flag."

    After making that change, the examples work

    I have not applied the patch until conformation. (Attached is the patch)
    Attached Files Attached Files

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Patch applied to SVN.

    It makes the DiceWar GUI nice and fast

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Oh very nice, you found the bug that was totally puzzling me. Great work.

Similar Threads

  1. Python as a win32 gaming platform
    By jjohn in forum Game development
    Replies: 1
    Last Post: 03-09-2007, 02:42 AM
  2. Sending message to server
    By croland in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-24-2006, 03:56 PM
  3. Awesome, i'm the first message in here!
    By Uhfgood in forum Novashell Game Creation System
    Replies: 1
    Last Post: 11-11-2006, 03:35 AM
  4. Message for DUck
    By dink holland smallwood in forum Dink Smallwood HD
    Replies: 0
    Last Post: 11-24-2004, 11:32 AM
  5. Customized error message
    By File Sponge in forum Funeral Quest
    Replies: 2
    Last Post: 08-13-2004, 12:33 AM

Bookmarks

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
  •