Game Design, Programming and running a one-man games business…

Crappy windows code

Soo… some people have a bug in GSB where in fullscreen mode, the titlebar of the windows ‘window’ is still there, but invisible, meaning you can accidentally hit the close or miniomize buttons, or worse-still, double click and then ‘maximise’ the already fullscreen window.

I have encountered this a few times in GSB myself. but cannot reproduce it right now. It’s certainly not reliable. And it’s annoying. I would love to fix it. I’m pretty sure its something to do with the windows code that selects either a windows style or windows class.

currently I use:

wcex.style            =    CS_CLASSDC | CS_DBLCLKS;

and

HWND gWnd = CreateWindow(appname,appname,
 WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
 0,0, width, height, GetDesktopWindow(), NULL, hInstance, NULL);

Both chunks of code I haven’t changed in ages. I suspect the code is wrong, but am finding it impossible to find what is ‘correct’. Looking at the directx samples makes me want to cry. In amongst 500,000 pages of incredibly convoluted, confusing, totally over-engineered MFC style bullshit that they call ‘DXUT’, there is a hint that microsoft themselves use just CS_DBLCLKS and WS_OVERLAPPED. The thing is WHY? There is no documentation. In the old days, directx5 used to tell us we need to use WS_TOPMOST or somesuch.

You would imagine that as 95% of people using directx write games, and 90% of them want to, at some point, run fullscreen, that the directx docs would have a line saying “for fullscreen apps, you need to select these options for your window”. No such clues have emerged though.  Another evenings trolling through coding forums no doubt…


9 thoughts on Crappy windows code

  1. I use:

    wcex.style = CS_HREDRAW | CS_VREDRAW

    and:

    WS_OVERLAPPEDWINDOW

    which I picked up from ‘3D Game Programming with DirectX9 a shader approach’. I don’t use any of the other WS_ codes you have there on create.

    When it goes fullscreen I use SetWindowLongPointer(pWnd, GWL_STYLE, WS_POPUP );
    followed by SetWindowPos(more params here) ;

  2. I have read developers suggest that directx itself forces the popup style once the game grabs excklusive mode and enters fullscreen, but I haven’t stepped through debug code to verify that.
    It’s all way too vague for my liking :D

  3. The following style setting should take care of everything but the close button:

    WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX

    However, I think all you *should* need for style in fullscreen mode is:

    WS_POPUP | WS_VISIBLE

    I’ve also seen games use the “topmost” extended style:

    CreateWindowEx(WS_EX_TOPMOST, appname, appname,
    WS_POPUP | WS_VISIBLE, …

    Another thing you should keep in mind: as I was trying to find a better description of WS_POPUP (other than “Creates a pop-up window. This style cannot be used with the WS_CHILD style.” >.<) I noticed a few complaints that WS_POPUP behaves differently on Vista (and I assume Windows 7) than it does on XP.

    Yay Microsoft!

  4. I again refer you to stackoverflow for this kind of thing. If it isn’t already answered there, post your question and you will have your answer usually within the hour.

  5. Just out of curiosity, have you ever considered using OpenGL? If so, why haven’t you pursued it, and if not then why not? I can only imagine that it would facilitate going cross-platform, and OpenGL, while filled with just as many complexities, seems a lot more, for lack of a better term, feature stable from release to release and with a lot more quickly accessible information. Not that I’m immersed in either library to say that with confidence, it’s just my general impression from periodically tackling 3D programming from time to time.

  6. Just in case you didn’t notice it on the forums, and for anyone who has the problem and reads this, a solution has been found. The user can right-click on GSB.exe, select properties, go to the compatibility tab, and disable visual themes. This completely resolves the problem.

Comments are currently closed.