• Welcome to Dark Bit Factory & Gravity.
 

Basic window setup

Started by Stonemonkey, September 28, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

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

Jim

Looks OK to me :)

I see one tiny bug

        if (!GetMessage(&msg, fetch_project()->window, 0, 0))
            break;

should be

        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
Challenge Trophies Won:

Stonemonkey

#2
Heh, cheers Jim. I am surprised that's all tbh. I'll fix that and uplaod again.

EDIT: sorted.

Jim

Might be more in there, but the structure looks OK, which is far more important. :)
Jim
Challenge Trophies Won:

Stonemonkey

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.

Shockwave

Thanks for posting :) K+
Shockwave ^ Codigos
Challenge Trophies Won:

Stonemonkey

#6
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:


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 :(

ninogenio

#7
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.
Challenge Trophies Won:

Jim

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
Challenge Trophies Won:

Stonemonkey


Paul

That gfx mode doesn't work on my pc :(
anything i could do to make it work?
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Stonemonkey

Hi paul, what's happening exactly? are the results the same whether it's fullscreen or windowed?

stonemonkey.

Paul

hehe. I most have had more than 1 tab going, I was supposed to post that in Shockwaves 32b topic :P
sry
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Stonemonkey

lol, no problem.

Fryer.