Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: Stonemonkey on September 28, 2007

Title: Basic window setup
Post by: Stonemonkey on September 28, 2007
I'm trying to re organise things in my code a bit and thought this may (or may not) be useful. It's the basic window and gfx buffer setup I'm using based on Jims code. It's been modified quite a bit though and if anyone that knows any better thinks that something could/should be done differently I'd be grateful of any input.

You'll need to create an empty win32 project and put these files into it (I think they're all there).
Title: Re: Basic window setup
Post by: Jim on September 28, 2007
Looks OK to me :)

I see one tiny bug
Code: [Select]
        if (!GetMessage(&msg, fetch_project()->window, 0, 0))
            break;
should be
Code: [Select]
        if (GetMessage(&msg, fetch_project()->window, 0, 0)>0)
            break;
since GetMessage returns < 0 on error, 0 for exit, and > 0 for success.  I can't imagine any situation where that would happen on a stable system though.

Jim
Title: Re: Basic window setup
Post by: Stonemonkey on September 29, 2007
Heh, cheers Jim. I am surprised that's all tbh. I'll fix that and uplaod again.

EDIT: sorted.
Title: Re: Basic window setup
Post by: Jim on September 29, 2007
Might be more in there, but the structure looks OK, which is far more important. :)
Jim
Title: Re: Basic window setup
Post by: Stonemonkey on September 29, 2007
Yeah, I hadn't expected you'd gone through it all but if that's about the worst that stands out I'll be quite happy.
Title: Re: Basic window setup
Post by: Shockwave on September 29, 2007
Thanks for posting :) K+
Title: Re: Basic window setup
Post by: Stonemonkey on November 25, 2007
Hmmm. Jim, I've just been looking back at something and made the change you suggested and now the windows aren't working at all right, they can't be dragged, the buttons don't work and I don't get feedback from the mouse. Should it have been:

Code: [Select]
if (GetMessage(&msg, fetch_project()->window, 0, 0)<0)
            break;

as that appears to get everything working.

EDIT:
Sorry to anyone trying to run that code as it would've just given a blank screen :(
Title: Re: Basic window setup
Post by: ninogenio on November 25, 2007
strange i use GetMessage()>0 in my code and it works fine although i use NULL where you youse fetch_project is the fetch project window needed?

edit sorry just went through your code, you do things diffrent to me so maybe < 0 is more correct in your case.
 
Title: Re: Basic window setup
Post by: Jim on November 25, 2007
Should be <=.  Just check the docs for GetMessage.  It returns 0 when WM_QUIT comes through and -ve on error.  So just "if (GetMessage())" isn't right, but then again, I got the check wrong too :(

Jim
Title: Re: Basic window setup
Post by: Stonemonkey on November 26, 2007
Thanks Jim.
Title: Re: Basic window setup
Post by: Paul on November 26, 2007
That gfx mode doesn't work on my pc :(
anything i could do to make it work?
Title: Re: Basic window setup
Post by: Stonemonkey on November 27, 2007
Hi paul, what's happening exactly? are the results the same whether it's fullscreen or windowed?

stonemonkey.
Title: Re: Basic window setup
Post by: Paul on November 28, 2007
hehe. I most have had more than 1 tab going, I was supposed to post that in Shockwaves 32b topic :P
sry
Title: Re: Basic window setup
Post by: Stonemonkey on November 30, 2007
lol, no problem.

Fryer.