Jump to content
  • Advertisement
Sign in to follow this  

WM_SYSCOMMAND and moving a window

This topic is 4077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get my game to render while you drag the window. The way I'm doing this is to set a timer when I get WM_ENTERSIZEMOVE, tick my main loop once in WM_TIMER, and then kill the timer at WM_EXITSIZEMOVE. However, when I start dragging the window, there's a delay of around 500ms before I get the WM_ENTERSIZEMOVE message. I've tracked this down to WM_SYSCOMMAND. Here's a dump of all window messages and the time they're recieved:
Quote:
WM_SYSCOMMAND(SC_MOVE) at 12998015 WM_CAPTURECHANGED at 12998515 WM_GETMINMAXINFO at 12998515 WM_WINDOWPOSCHANGING at 12998515 WM_GETMINMAXINFO at 12998515 WM_ENTERSIZEMOVE at 12998515 WM_MOVING at 12998515 WM_NCMOUSELEAVE at 12998515 WM_TIMER at 12998515
As you can see, there's a 500ms delay between WM_SYSCOMMAND and the next message. All this happens in on call to PeekMessage(). I thought about returning 0 from WM_SYSCOMMAND, but that seems to disable moving the window completely. So, I have 3 questions: 1) What does DefWindowProc do? Why does it wait half a second before issuing WM_CAPTURECHANGED (I've logged this to hell, DefWindowProc doesn't call my wnd proc (it recurses) for 500ms)? 2) Is returning 0 from WM_SYSCOMMAND for SC_MOVE a reasonable thing to do, and if so, what do I need to do to enable the size-move modal loop? 3) Are there any better ways than the mess of WM_TIMER and size-move modal loop stuff that I'm doing? Threading is an option, but I'd prefer to avoid it if possible. I have thread classes already, but I imagine there's a few pitfalls of processing window messages in a thread? Cheers, Steve

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Endurion
The code monster that DefWindowProc is is probably the most secret routine of Windows :)

Why don't you create your timer in WM_SYSCOMMAND on SC_MOVE? Does it make a difference?
Yeah, I just thought someone might have some idea [smile]

The DefWindowProc for WM_SYSCOMMAND doesn't return for 500ms, which means that the next WM_TIMER message isn't picked up till the next run through my window loop, so placing the SetTimer() in WM_SYSCOMMAND doesn't have any different effect.

Cheers,
Steve

Share this post


Link to post
Share on other sites
Have you tried with an "normal" window? I think maybe your renderer interferes with the common process.

Anyway, if you choose not to pass the message on to DefWindowProc you'll have to add all the sizing/moving functionality yourself. While it's certainly possible (I've tried and went nuts) i wouldn't do it.

I really suspect that the renderer is the culprit. From the sounds of it also the actual dragging of the window should lag for half a second. Or does it happen at an instant?

Share this post


Link to post
Share on other sites
Quote:
Original post by Endurion
Have you tried with an "normal" window? I think maybe your renderer interferes with the common process.

Anyway, if you choose not to pass the message on to DefWindowProc you'll have to add all the sizing/moving functionality yourself. While it's certainly possible (I've tried and went nuts) i wouldn't do it.

I really suspect that the renderer is the culprit. From the sounds of it also the actual dragging of the window should lag for half a second. Or does it happen at an instant?
I haven't tried with a "normal" window no, I'll try that at lunch time (15 mins).
EDIT: Yup, still does it.

My renderer is Direct3D, rendering in WM_PAINT and once per tick (Windowed mode, obviously).
If I click on the window title bar and don't move the mouse, I get te half second lag, but if I drag the window right away, I don't get the lag at all. It's as if Windows is waiting for something, but I don't know what...

[Edited by - Evil Steve on March 22, 2007 8:37:25 AM]

Share this post


Link to post
Share on other sites
Hey,

What you do looks pretty complicated to me. I personally used an extra thread for doing this, and it works like a charm. I use the WM_NCHITTEST message though --as I wanted to let the user drag the entire window by simply clicking on it.
Have you tried with that message ?

Also, what is it *exactly* you want to do ? Enabling moving *AND* resizing, or just moving ?
Cheers
StratBoy61

Share this post


Link to post
Share on other sites
Quote:
Original post by StratBoy61
Hey,

What you do looks pretty complicated to me. I personally used an extra thread for doing this, and it works like a charm. I use the WM_NCHITTEST message though --as I wanted to let the user drag the entire window by simply clicking on it.
Have you tried with that message ?

Also, what is it *exactly* you want to do ? Enabling moving *AND* resizing, or just moving ?
Cheers
StratBoy61
I think I'm just going to give up with this. It's not really a problem, it's just a freeze if you click on the title bar and do nothing for 500ms.
I haven't tried the WM_NCHITTEST stuff, but I'd like to keep things as simple as possible (ha!), and let windows do the moving / sizing. At the moment, I'm only handling the moving, but it'd be nice to handle the sizing too. This is for a generic engine I'm writing, and the game code shouldn't care what's going on, so long as the timers are all up to date.

Share this post


Link to post
Share on other sites
Couldn't you just always render on WM_TIMER?
It could limit your framerate, but if that's acceptable it would also solve your problem and render when resizing/moving etc.
However I have noticed when I use such a solution that there is sometimes a delay like the one you wrote about if one just clicks the title bar and doesn't actually move the window..
Perhaps it has something to do with this, from MSDN:
Quote:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.


For return values etc. you should search for the messages on MSDN, there is usually information on what value to return when handling a message.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!