• 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
Aressera

Problems with SetParent() and window frames

4 posts in this topic

I'm trying to implement a cross-platform wrapper for basic window management and OpenGL rendering. I've gotten the OS X version working well. To create an OpenGL rendering view I create an NSOpenGLView (on mac) or an HWND with the WS_CHILD style, then attach the view to a normal window, allowing the user to position the view anywhere in the window.

However, there is something weird that happens whenever I call SetParent() to make the GL view a child window of a normal window - the GL view is resized so that it fits inside in the parent window, but the strange thing is that it is reduced in size by the same amount as if it had a title bar/frame. The result is that there is now a border around the GL view between it and the parent window. This happens even if the client rectangle of the GL view and the normal window should be the same size. (I've attached an image of the behavior).

I should note that it does work as expected unless I call SetWindowPos() to update the frame. SetWindowPos() shouldn't move or size the window if I specify the flags SWP_NOMOVE and SWP_NOSIZE, but it does anyway.

As far as I'm aware, a window with the WS_CHILD style shouldn't have any title bar or frame but it seems like somewhere the windows API treats them as such.

I've spent several hours trying to find a workaround to this apparent problem. Does anyone have any idea what I could be doing wrong, or is there no way I can do what I'm trying to do?

Here is a rundown of the API calls I'm making that cause the problem:[list=1]
[*]CreateWindowEx() for the GL view with the WS_POPUP style. I use that style because I can't seem to create a window with the WS_CHILD style without specifying a parent window at creation. This also allows me to switch the GL view to fullscreen when running in non-windowed mode. I use a size of 800x600 for the window.
[*]Change the style of the window from WS_POPUP to WS_CHILD using SetWindowLongPtr() in order to prepare it to be a child of another window.
[*]Call SetParent() to make the GL view a child of the normal window.
[*]If I call SetWindowPos() at any point after making the GL view a child, it resizes the GL view's client rectangle as described above. The resulting client area rectangle is 780x560, even though the window was created with a client size of 800x600. This makes the invisible frame of the GL view fit within the original 800x600 size.
[/list]
0

Share this post


Link to post
Share on other sites
[quote name='Aressera' timestamp='1347080200' post='4977901']
I should note that it does work as expected unless I call SetWindowPos() to update the frame. SetWindowPos() shouldn't move or size the window if I specify the flags SWP_NOMOVE and SWP_NOSIZE, but it does anyway.
[/quote]

Can you please specify the arguments assigned to SetWindowPos parameters + full list of GlView styles? Edited by Eliad Moshe
0

Share this post


Link to post
Share on other sites
Also, of course child windows can also have a border. What style parameters are you setting when calling CreateWindow(Ex) on the child window?

Show the creation code, message pump and window procs (both parent and child) Edited by Endurion
0

Share this post


Link to post
Share on other sites
I'll work up a minimal code example tomorrow demonstrating the issue. I create the child window with the WS_POPUP and WS_CLIP_SIBLINGS style flags. When I make the child window a child of the normal window, I remove the WS_POPUP style and set the WS_CHILD style.

I am calling SetWindowPos( childHandle, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED ) which should just make sure that the cached window frame state is up to date but instead displays the problematic behavior.
0

Share this post


Link to post
Share on other sites
I did some more digging and realized that if I handle the WM_NCCALCSIZE message and return 0, the call to SetWindowPos that previously caused the problem worked as expected. It preserves the size of the client rectangle.

The bizarre thing is that before this change, if I added a menu bar to the parent window, that blank frame around the GL view was sized to fit a menu and title bar. I guess if you don't handle that message, the parent window provides the default behavior which obviously wasn't what I wanted...

Everything works great now!
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