• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Evil Steve

WM_SYSCOMMAND and moving a window

8 posts in this topic

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
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
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
0

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?
0

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]
0

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
0

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.
0

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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0